Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpSliderPresenter doesn't behave well. Dragging it makes the handle jump erratic between min and max value #1595

Open
ironirc opened this issue Sep 7, 2024 · 2 comments
Assignees

Comments

@ironirc
Copy link
Contributor

ironirc commented Sep 7, 2024

A possible resolution might be following method change.

SpMorphicSliderAdapter>>#buildWidget
...
self presenter whenValueChangedDo: [ :newValue |
preWidget value: self absoluteValue ].
...

In other words, the preWidget value should be set with the absoluteValue (instead of using newValue)

@antonello-chessa
Copy link

antonello-chessa commented Sep 9, 2024

Yes @ironirc, your conclusion matches the results I found by doing some tests. I modified SliderMorph>>value: adding the following diagnostic instruction:
Transcript show:('SliderMorph value: sent with:{1} by {2}'format:{newValue . thisContext sender});cr.
And it shows that the wrong value is assigned by the block assigned to self presenter whenValueChangedDo: whitin SpMorphicSliderAdapter>>buildWidget. The issue was indeed that the value needed to be converted to absolute value(which is the ratio (value-min)/(max-min) with values in [0,1]). Without that conversion the instruction in:

SliderMorph>>value: newValue
   ...
   value := newValue min:1 max:0.
   ...

would truncate the value of newValue to 1 and then assign it to value causing the thumb to be drawn on the right at the position associated to the highest slider value. That was the cause of the erratic behavior of the thumb, because, both when clicking and dragging it was jumping between being drawn at the end of the slider and at the correct position.

@Ducasse
Copy link
Contributor

Ducasse commented Sep 9, 2024

Hi guys
Thank you for opening this issue.
We will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants