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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Image Analyst
Image Analyst le 20 Mar 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);

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by