Positioning of the slider by just a single click

1 回表示 (過去 30 日間)
Philipp
Philipp 2018 年 11 月 21 日
回答済み: Jan 2018 年 11 月 21 日
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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by