Can the uiconfirm 'Cancel' response be used to directly stop the current callback?
4 次查看(过去 30 天)
显示 更早的评论
I currently use the questdlg to solicit a user response, paired with an if-statement to stop callback execution. Below is a short example of the code I typically use.
% Prompt the user to respond on how to proceed.
qans = questdlg('Do you wish to proceed?','Confirm to Proceed','Yes','No','Yes'); % Default button set to 'Yes'
% End callback function if the close dialog (X) or 'No' buttons are pushed
if isempty(qans) || strcmp(qans,'No')
return
end
% Else continue with the remainder of the callback function
However, uiconfirm appears to allow the user to assign a CloseFcn for 'Cancel' responses, which includes the close dialog box. I would like to be able to assign return as the CloseFcn, but this is not directly allowed. The following are my attempts at this.
% Attempted to use the @mycallback function as shown in the Help
% documentation. This does not immediately terminate the callback.
qans = uiconfirm(app.UIFigure,"Do you wish to proceed?","Confirm to Proceed", ...
"Options",["Yes","Cancel"],"DefaultOption",2,"CancelOption",2,"CloseFcn",@mycallback);
% Attempted to use return and @return directly within uiconfirm, but this
% is not a valid use of return.
qans = uiconfirm(app.UIFigure,"Do you wish to proceed?","Confirm to Proceed", ...
"Options",["Yes","Cancel"],"DefaultOption",2,"CancelOption",2,"CloseFcn",return);
Is there another way to do this firectly within uiconfirm?
0 个评论
采纳的回答
Walter Roberson
2021-7-12
No. There is no way to do that.
2 个评论
Walter Roberson
2021-7-12
Except for a few callbacks that act as filters constraining ROI positions or zooming positions, all callbacks in MATLAB are executed in the base workspace (if they are not function handles) or as-if invoked from the top level. Their caller is not the function that invoked uiconfirm()
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!