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)
6 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!