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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 20 Mär. 2013
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);

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by