Also, I'd love to convert my GUIDE to AppDesigner, but Set/Get -Access Observability is 'off' for almost everything in AppDesigner.
Circular Listeners (2 objects listening to each other)
3 views (last 30 days)
Show older comments
I have a data class and a GUIDE figure to help interact with the data. One of the properties of the class is a threshold value, so the figure has a threshold textbox. I'd like to set up listeners such that changing either side (the textbox "string" or the data class property) will update the other.
I was afraid I'd end up in an infinite loop, but it appears MATLAB is smart enough to only execute each listener once. However, this means that 2 events fire for a single value change. This is further complicated by the fact that the textbox uses the "string" property, so the data class ends up being character, not numeric.
Datavar.Value = 1;
% First listener fires, sets edit1.String to '1'
% Second listener fires, sets Datavar.Value to '1'
Datavar.Value
ans =
'1'
I've attached a minimal working example. To test it:
a = gui1;
handles = guidata(a);
EL = handles.TestEL_Object;
EL.Property1 = 8;
EL.Property1
I could utilize the "UserData" property and implement a str2double call, so at least the double-firing wouldn't change the value. Any ideas on getting it to only fire one event? I can imagine my situation getting more computationally expensive, so the second execution would hurt.
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!