App Designer, addlistener for slider

12 次查看(过去 30 天)
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 个评论
Rasmus Steffensen
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 2018-7-6
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!!

请先登录,再进行评论。

采纳的回答

Madeline Gardner
Madeline Gardner 2018-7-6
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 个评论
Mihail Dadun
Mihail Dadun 2019-11-11
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 2023-8-30
Genius! This works just finely. "value.Event" is the answer!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by