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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Image Analyst
Image Analyst el 20 de Mzo. de 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);

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by