Can the uiconfirm 'Cancel' response be used to directly stop the current callback?

7 ビュー (過去 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?

採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 12 日
No. There is no way to do that.
  2 件のコメント
Allen
Allen 2021 年 7 月 12 日
Walter,
Thanks for the response. I will just continue using my current method.
Walter Roberson
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 ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by