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

7 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by