Positioning of the slider by just a single click

3 次查看(过去 30 天)
Dear all,
I am using sliders in a GUI as visual analogue scales for perceptual experimentation.
One question regarding the positioning of the slider: One can control the slidersteps (small and large ones) easily by controlling the SliderStep property of the slider. Would it also be possible to immediately position the slider at any position with just one click at any position in the area of the slidebar, instead of triggering large steps when clicking in that area?
Thanks a lot
Best, Philipp

回答(1 个)

Jan
Jan 2018-11-21
This is not the standard behavior of sliders and as usual, implementing an unexpected behavior of a GUI element will confuse the users. Therefore I recommend not to try it.
You can check the current position of the mouse in the slider's callback, and if you detect a click on the bar, you can adjust the slider's 'Value' property such, that it equals the position of the mouse. This is not hard, but a little bit tedious: Maybe you have to get the position of the slider dynamically, what it has 'normalized' units and the figure is resizable. But there is always a method to get the slider's and mouse' position in pixels, such that implementing an individual method for moving the slider is possible. Try it and post the current code in case of problems.

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by