Creating Graphical User Interfaces Previous page   Next Page

Using Modal Figure Windows

Modal windows trap all keyboard and mouse events that occur in any visible MATLAB window. This means a modal GUI figure can process the user interactions with any of its components, but does not allow the user to access any other MATLAB window (including the command window). In addition, a modal window remains stacked on top of other MATLAB windows until it is deleted, at which time focus returns to the window that last had focus. See the figure WindowStyle property for more details.

Use modal figures when you want to force users to respond to your GUI before allowing them to take other actions in MATLAB.

Making a Figure Modal

Set the figure's WindowStyle property to modal to make the window modal. You can use the Property Inspector to change this property or add a statement in the initialization section of the GUI M-file in the opening function with the set command.

Dismissing a Modal Figure

A GUI using a modal figure must take one of the following actions in a callback routine to release control:

The user can also type Ctrl+C in a modal figure to convert it to a normal window.


Previous page  Controlling Figure Window Behavior Example: Using the Modal Dialog to Confirm an Operation Next page

© 1994-2005 The MathWorks, Inc.