Can the uiconfirm 'Cancel' response be used to directly stop the current callback?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Allen
le 12 Juil 2021
Commenté : Walter Roberson
le 12 Juil 2021
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 commentaires
Réponse acceptée
Walter Roberson
le 12 Juil 2021
No. There is no way to do that.
2 commentaires
Walter Roberson
le 12 Juil 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()
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!