Borrar filtros
Borrar filtros

App Designer, addlistener for slider

13 visualizaciones (últimos 30 días)
Rasmus Steffensen
Rasmus Steffensen el 6 de Jul. de 2018
Comentada: Raul el 30 de Ag. de 2023
Hi,
I want to update some plots when a slider control is moved, but i want it to update continuously when the slider is dragged. Is it possible to add a listener for the slider in the AppDesigner like with the usual uicontrol, as app.Slider.addlistener('Value', 'PostSet', @(es,ed)update_plot(es,ed,'zeta'));
However, i get an error: Error using matlab.ui.control.Slider/addlistener While adding a PostSet listener, property 'Value' in class 'matlab.ui.control.Slider' is not defined to be SetObservable.
Error in app1 (line 203) runStartupFcn(app, @startupFcn)
Do i have to do it differently?
Sincerely, Rasmus
  3 comentarios
Rasmus Steffensen
Rasmus Steffensen el 6 de Jul. de 2018
But this means it has different implementation than the slider = uicontrol('Style','slider' ... where the above code works fine? how do i get the same functionality with the app designer?
Adam
Adam el 6 de Jul. de 2018
App Designer still has a lot of limitations compared to regular Matlab code or Guide. I guess this is one of them. It seems the 'value' for these sliders is not setup to have observers.
You can use a java slider to achieve continuous callbacks, but it does involve more work and I've never tried including them in App Designer because I 'rage quit' last time I tried to create even a basic UI in App Designer!!

Iniciar sesión para comentar.

Respuesta aceptada

Madeline Gardner
Madeline Gardner el 6 de Jul. de 2018
Hello!
It looks like App designer has a ValueChanging callback for a slider that gets the value continuously as the slider updates! The syntax is a little different than the code you're referencing, but it should have the same output. This link has some information, but you can also go to callbacks under Slider Properties and select the ValueChangingFcn option. (I've attached just a basic screenshot of what this looks like in the App Designer interface)
Hope that helps!
  2 comentarios
Mihail Dadun
Mihail Dadun el 11 de Nov. de 2019
I've encountered the same problem and the ValueChanging (as opposed to ValueChanged) callback still does not provide continuous updates. As in, it updates (the value, implicitly the plot) just once, the only difference being that it does change it before the click release. However, if I keep sliding, it does not produce any results, until I release the click, click again, and briefly slide again. Could this be a bug?
Raul
Raul el 30 de Ag. de 2023
Genius! This works just finely. "value.Event" is the answer!

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.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by