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

3 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Jul. 2021
No. There is no way to do that.
  2 Kommentare
Allen
Allen am 12 Jul. 2021
Walter,
Thanks for the response. I will just continue using my current method.
Walter Roberson
Walter Roberson am 12 Jul. 2021
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()

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by