How do I get UIWAIT to work with a question dialog box in MATLAB?

10 views (last 30 days)
I am trying to open a dialog box, stop the program it is called from, then after a certain time, close the dialog box and return to the program.
The function UIWAIT works properly for the MSGBOX function:
uiwait(msgbox('Welcome to the Advection Program','Hello'),.2);
However, when I try to use it for the QUESTDLG function it does not work.
I am executing the following code:
uiwait(questdlg('Are you sure, you want to stop Realtime?','CloseRequestFunction','Yes','No','Yes'),.2);
After this, I close the dialog box. However, the following error is returned:
??? Error using ==> uiwait
Input argument must be of type figure

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jan 2010
You receive this error message using QUESTDLG because UIWAIT expects its first input argument to be a function handle (which is the case for MSGBOX, but not for QUESTDLG).
The attached file, 'My_questdlg.m' closely reproduces the operation of the question dialog box, and can be made to work with UIWAIT. You would have to modify it slightly to have it return an output string, if this is what you want.
In order to run this program, download the attached files into your working directory. Then run the following command at the MATLAB command prompt:
My_questdlg('Are you sure you want to stop Realtime?','Close Request Function','Yes','No')
This will open up a GUI similar to your question dialog box. If there is no user input, the figure is deleted and control is returned to the main program after an interval of 5 seconds.

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!