Borrar filtros
Borrar filtros

How do I make a text box in GUI that updates immediately when slider is moved?

15 visualizaciones (últimos 30 días)
I apologize if this is easy to figure out, but I'm exhausted on this Friday evening. I'm new to making GUIs. I want to have a GUI in which there is a slider and whenever the user changes the slider position, a text box immediately takes the value in the slider and displays it. In other words, I don't want there to be any guesses as to what value the slider is at, I want it to be displayed as soon as the slider position is changed. How do I make this textbox update the value of the slider dynamically like that?
Thanks!

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 8 de Nov. de 2014
Alexei - see the solution from make GUI slider behave like iOS frame scroller which will tell you how to create a continuous value change listener for the slider. The only thing that ail be missing is how to update the text box which you can do by just modifying the slider1ContValCallback (from the link) as
function slider1ContValCallback(hFigure,eventdata)
% test it out - get the handles object and write the current value
% to the edit box
handles = guidata(hFigure);
sliderValue = get(handles.slider1,'Value');
set(handles.text1,'String',num2str(sliderValue));
The above assumes that text1 is the tag for the text box that you wish to update, and that slider1 is the tag for your slider.
Try it out and see what happens!
  1 comentario
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis el 9 de Feb. de 2019
@ Geof Hayes : i just implemented your code but it updated numeric values instead of my text1's content sir. what should i do to update the content of text1 when i scroll up or down appropriately sir ?
please help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by