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)
조회 수: 2 (최근 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!