필터 지우기
필터 지우기

Positioning of the slider by just a single click

조회 수: 3 (최근 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 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