How can I restrict sliders movement without modify Max and Min properties?

1 回表示 (過去 30 日間)
I have two different sliders, one for a maximum value (MaxSlider) and another for a minimum value (MinSlider). (Working in a GUI using GUIDE)
Both of them work in this range = [0:300], but if MaxSlider(value)<MinSlider(value) the function that they call doesn't run (I'm ok with that).
I would like to keep the range, but I want to restrict sliders movement, I mean that user can't move MinSlider above MaxSlider.
I tried changing Max and Min properties, but this affect at range. Does anybody know a way to restrict slider movement without changing range?
Thank you very much.

採用された回答

Image Analyst
Image Analyst 2013 年 3 月 20 日
You can make up your own range in the slider callback with myMin and myMax that is different than the min and max property of the slider:
sliderValue = get(handles.slider1, 'Value');
if sliderValue > myMax
sliderValue = myMax;
elseif sliderValue < myMin
sliderValue = myMin
end
% Send the value back to the slider.
set(handles.slider1, 'Value', sliderValue);
guidata(hObject, handles);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by