Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Can you program a figure to execute the same callback after each child's callback?
조회 수: 1 (최근 30일)
이전 댓글 표시
Essentially, I'd like a callback that is for the figure and all of it's children, but is executed last. Of course, you could manually enter this code for every single callback, but perhaps there is a more elegant way?
fh = figure()
button1 = uicontrol('Parent', fh, 'Callback', button1_Callback)
button1 = uicontrol('Parent', fh, 'Callback', button2_Callback)
%...
buttonN = uicontrol('Parent', fh, 'Callback', buttonN_Callback)
function button1_callback(hObject, eventD, fh)
% Do stuff specific to this object.
% Perform this action (***I don't want to type this for every single callback***)
fh_callback(fh, eventD, fh); % Example.
end
function button2_Callback(hObject, eventD, fh)
% Do stuff specific to this object.
% Perform this action (***I don't want to type this for every single callback***)
fh_callback(fh, eventD, fh); % Example.
end
%...
function buttonN_Callback(hObject, eventD, fh)
% Do stuff specific to this object.
% Perform this action (***I don't want to type this for every single callback***)
fh_callback(fh, eventD, fh); % Example.
end
댓글 수: 6
답변 (1개)
Steven Lord
2019년 7월 11일
Are you setting the figure object's CurrentObject property back to the figure object itself because your callbacks query the CurrentObject to determine what component to query or modify? That could be dangerous -- all it would take would be the user clicking in the wrong place at the wrong time to potentially break your UI by making the CurrentObject not what your callbacks expect it to be.
Instead, I would store the handles of the components in your UI and share the stored handles among the callbacks. That way you don't need to care what the current CurrentObject is, you can refer to either the object whose callback is currently executing (the first input to the callback function) or to a specific object whose handle is in the shared data.
댓글 수: 1
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!