-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Add option to update when releasing mouse button from slide #2228
Conversation
Thank you! Looks good so far code-wise, but I was thinking more about this and maybe it's not quite the right solution. The problem as I see it is that this way, if you have a slider and a text field for example, the text field would also not update while you drag the slider, which is potentially confusing or unhelpful because the user might want to stop dragging knowing they're at the right position. So I thought, maybe it's easier to just add a second output observable, with a name like The other option I thought about was to have an observable called |
Makes sense in general - of course my approach fit my immediate needs and wants :-) However, you have a good example with the textfield views. I'll have to think a little about implementing something along the lines of what you propose. A lot of effort the first effort was trying to get the general code structure and operation, so now time to dig deeper |
The approach would be almost exactly what you have, just remove the input observable you added, and add an output observable there just like |
I've now pushed code that should have the approach discussed above implemented. I added a new example to the docs to help demo the behavior as well. |
docs/examples/blocks/slider.md
Outdated
If the slider value is used for a relatively slow task, it may be more effective to | ||
use the attribute `value_dragstop` instead of `value`. The `value_dragstop` is only | ||
updated when the mouse is released to conclude the slider drag operation. It is | ||
is synchronized with `value` when calling `set_cloe_to!(slider, value)` or one a mouse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_cloe_to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section should go before the example I think, with an appropriate subheading
src/makielayout/blocks/slider.jl
Outdated
(event.px[2] - endpoints[][1][2]) / (endpoints[][2][2] - endpoints[][1][2]) | ||
end, 0, 1) | ||
# dif is never used? | ||
# dif = event.px - event.prev_px |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments can be removed then
The example should also have some small explanatory sentence probably, something like "In the following example one slider updates when ... and the other ... |
This is actually a really nice PR! @lwhitefox, do still want to finish it or do you require some help? |
I had some issues with email notifications for a while and missed updates from you and @jkrumbiegel - I'll get back to this in the next couple of days, it is good to have the reminder! |
@SimonDanisch I've finished up the tasks for this PR; I did have to wrestle with git and GitHub a bit to get synchronized again so hopefully the updated code and .md file are pushed here successfully |
@jkrumbiegel do you think this is ready now? |
This would be a very welcome addition! |
I'm closing this in favor of #3231. Thanks for your work and the valuable discussion here @lwhitefox, if you're still interested you can check out the other PR and see if it satisfies your needs as well. The implementation is a bit different as I decided I found one output observable simpler and a bit more flexible, too. |
Description
Fixes # (issue)
Added the option
drag_update
to Slider. If true, updates selected index while dragging; otherwise only does update on mouse release. Thus if true, graphics will update while dragging the slider in common usage. If false, graphics update only on mouse release, which may be useful if updates rely on comparatively slow calculations for example.In addition a couple lines of code that appear to have no function in current implementation were identified and commented out with a note added to allow them to be found easily.
Type of change
Delete options that do not apply:
Checklist