Azzera filtri
Azzera filtri

App Designer, addlistener for slider

13 visualizzazioni (ultimi 30 giorni)
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 Commenti
Rasmus Steffensen
Rasmus Steffensen il 6 Lug 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 il 6 Lug 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!!

Accedi per commentare.

Risposta accettata

Madeline Gardner
Madeline Gardner il 6 Lug 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 Commenti
Mihail Dadun
Mihail Dadun il 11 Nov 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 il 30 Ago 2023
Genius! This works just finely. "value.Event" is the answer!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by