about uicontrols and dialog

4 visualizaciones (últimos 30 días)
omid
omid el 8 de Nov. de 2017
Comentada: omid el 11 de Nov. de 2017
In my program I used a "helplg" dialog and when I close the dialog, I want the program to be terminated not same as pressing "ok" button the program be continued. In other word, when I close the helpdlg the program to be terminated not as pressing ok it follow the code instructions. How should I code this issue?
Thanks for your help

Respuestas (1)

Geoff Hayes
Geoff Hayes el 8 de Nov. de 2017
omid - please clarify how you are using this dialog. Also, why are you using a help dialog to terminate the program?
You may be able to use the CloseRequestFcn of the dialog to capture when the user has closed the dialog (by pressing the x in the top right corner). The following code "works" on R2014a, but I would recommend finding an alternative to using a help dialog.
function sampleDialogTest
isDialogClosed = false;
h = helpdlg('Sample dialog text');
set(h,'CloseRequestFcn', @HelpDialogClosed);
uiwait(h);
if isDialogClosed
fprintf('user pressed x so ending processing...\n');
return;
end
fprintf('user pressed ok so continuing with processing...\n');
function HelpDialogClosed(hObject, eventdata)
isDialogClosed = true;
closereq;
end
end
We nest the CloseRequestFcn in the main function so that it has access to the isDialogClosed boolean. uiwait is used to halt processing until the dialog is closed at which point we check our boolean - if true, then we end processing through return. And if false, then we continue.
  1 comentario
omid
omid el 11 de Nov. de 2017
Thanks Mr Hayes for your answer it was very helpful

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by