Getting GUI Slider updates while dragging

10 visualizaciones (últimos 30 días)
Norton Allen
Norton Allen el 23 de Oct. de 2012
Respondida: AG el 20 de Feb. de 2019
Is there a straightforward method to get updates on a slider's position while it is being dragged? The standard callback gets called only after the drag is complete and the button has been released.
I'm thinking of using the ButtonDownFcn to start a polling loop checking the slider's value. (Then how do I detect mouse up?)
  3 comentarios
Sean de Wolski
Sean de Wolski el 23 de Oct. de 2012
ButtonDownFcn is disabled over an enabled uicontrol
Norton Allen
Norton Allen el 24 de Oct. de 2012
Editada: Norton Allen el 24 de Oct. de 2012
Matt, what I'm trying to do is get a slider where the app updates while the slider is moving, for example the way a browser updates while you are moving the scroll bar.
Sean, I did discover that ButtonDownFcn is not the answer pretty quickly too!

Iniciar sesión para comentar.

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 23 de Oct. de 2012
This can be done easily with addlistener
h = uicontrol('style','slider','callback',@(src,evt)disp(get(src,'value')));
addlistener(h,'Value','PreSet',@(~,~)disp('hi'));
  3 comentarios
Mohamad Roslan Mohd Roshdi
Mohamad Roslan Mohd Roshdi el 24 de En. de 2016
Hi How to get the slider update value into variable?

Iniciar sesión para comentar.

Más respuestas (1)

AG
AG el 20 de Feb. de 2019
The following worked for me. I get a 'live' scroll-bar update by calling this within another function:
slider_value = get(gcf.Children(j), 'Value');
...where j is the value of the UIcontrol corresponding to the scroll. You can find out which UIControl it is in the figure by putting a break in the code and using:
gcf.Children
This could also be ascertained in run-time using:
for j = 1:length(gcf.Children)
get(gcf.Children(j), 'Tag')
end
which will return a char array with the Tag of each of the children which could then be compared using strcmp(), for example. I've done this using a GUI created with GUIDE.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by