Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Disable figure closing by clicking on the cross

Subject: Disable figure closing by clicking on the cross

From: Alessandro Salatiello

Date: 5 Jan, 2011 11:03:04

Message: 1 of 7

Hi everyone!

In my gui interface I want user to be blocked from doing anything, until a dialog box is closed.
I've thought of using :
>>uiwait(dialog)

but if the user clicks on the cross to close the window, he can do everything!

Excuse me for my english :D

Subject: Disable figure closing by clicking on the cross

From: Alessandro Salatiello

Date: 5 Jan, 2011 11:44:04

Message: 2 of 7

[I also want the computer to go on executing its function while the dialog box blocks the user]

Subject: Disable figure closing by clicking on the cross

From: Jan Simon

Date: 5 Jan, 2011 12:02:05

Message: 3 of 7

Dear Alessandro,

> but if the user clicks on the cross to close the window, he can do everything!

Clicking on the cross calls the CloseRequestFcn of the figure. So just define it following your demands, e.g.:
  figure('CloseRequestFcn', 'disp(''Do not click me!'')');
To close the figure programmatically, you have to set the CloseRequestFcn to '' or the default 'closereq'. Otherwise the figure is immortal!

But blocking the user is not a friendly method and a nervous user will press Ctrl-C soon.

Kind regards, Jan

Subject: Disable figure closing by clicking on the cross

From: Andy

Date: 5 Jan, 2011 14:11:05

Message: 4 of 7

"Alessandro Salatiello" <lizander911@gmail.com> wrote in message <ig1j58$8tf$1@fred.mathworks.com>...
> Hi everyone!
>
> In my gui interface I want user to be blocked from doing anything, until a dialog box is closed.
> I've thought of using :
> >>uiwait(dialog)
>
> but if the user clicks on the cross to close the window, he can do everything!
>
> Excuse me for my english :D

Most of MATLAB's dialog boxes have an option called 'modal' which does what you seem to want. Out of curiosity, what are you actually trying to do? Is this dialog box preventing the user from continuing to use the GUI while some process is running? Are you getting necessary data from the user, and they can't move on until they give the data?

Subject: Disable figure closing by clicking on the cross

From: Alessandro Salatiello

Date: 5 Jan, 2011 14:21:04

Message: 5 of 7


> Most of MATLAB's dialog boxes have an option called 'modal' which does what you seem to want. Out of curiosity, what are you actually trying to do? Is this dialog box preventing the user from continuing to use the GUI while some process is running? Are you getting necessary data from the user, and they can't move on until they give the data?

Yes, exactly!
The problem is that uiwait(dialog) bloks every process execution!!

Subject: Disable figure closing by clicking on the cross

From: Matt Fig

Date: 5 Jan, 2011 15:10:23

Message: 6 of 7

"Alessandro" wrote in message <ig1uog$c27$1@fred.mathworks.com>...
>
> > Most of MATLAB's dialog boxes have an option called 'modal' which does what you seem to want. Out of curiosity, what are you actually trying to do? Is this dialog box preventing the user from continuing to use the GUI while some process is running? Are you getting necessary data from the user, and they can't move on until they give the data?
>
> Yes, exactly!
> The problem is that uiwait(dialog) bloks every process execution!!

I find that setting the appropriate UICONTROL's enable property to 'off' or 'inactive' while the process is running, along with an appropriate indication to the user, is an effective way of dealing with this type of situation. Just don't forget to set the 'enable' property back to 'on' when the process is finished.

Subject: Disable figure closing by clicking on the cross

From: Yair Altman

Date: 18 Feb, 2011 09:13:04

Message: 7 of 7

"Alessandro" wrote in message <ig1uog$c27$1@fred.mathworks.com>...
>
> > Most of MATLAB's dialog boxes have an option called 'modal' which does what you seem to want. Out of curiosity, what are you actually trying to do? Is this dialog box preventing the user from continuing to use the GUI while some process is running? Are you getting necessary data from the user, and they can't move on until they give the data?
>
> Yes, exactly!
> The problem is that uiwait(dialog) bloks every process execution!!


Try using the enableDisableFig utility on the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/15895-enabledisable-figure

It makes the entire figure disabled without blocking processing

Yair Altman
http;//UndocumentedMatlab.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us