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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by