Window style, specified as one of the following:
'normal'
— The figure window is independent of other windows, and the other windows are accessible while the figure is displaying.
'modal'
— The figure displays on top of all existing figure windows, making them inaccessible as long as the top figure exists and remains modal. However, any new figures created after a modal figure will display.
When multiple modal windows exist, the most recently created window keeps focus and stays above all other windows until it becomes invisible, or is returned to a normal window style, or is deleted. At that time, focus reverts to the window that last had focus.
Note
These are some important characteristics of the WindowStyle
property and some recommended best practices:
When you create UI windows, always specify the
WindowStyle
property. If you also want to set
the Resize
or Position
properties of the figure, then set the WindowStyle
property first.
You can change the WindowStyle
property of a figure at any time, including when the figure is visible and contains children. However on some systems, setting this property might cause the figure to flash or disappear and reappear, depending on the system's implementation of normal and modal windows. For best visual results, set the WindowStyle
property at creation time or when the figure is invisible.
UI Figure Modal Window Style Behavior
When WindowStyle
is set to 'modal'
, the UI figure window blocks keyboard and mouse interactions in a UI figure window that was created before it and has its Visible
property set to 'on'
. For instance, in this example Figure 3 is modal with respect to Figure 2 and Figure 2 is modal with respect to Figure 1.
The modality hierarchy is not preserved if there is a combination of modal and normal figures in the hierarchy of figures.
Unlike modal figures created with the figure
function, modal figures created with the uifigure
function do not block access to figures created with the figure function or the MATLAB desktop. Interactions with application windows other than MATLAB are also not blocked.
Typing Ctrl+C when a modal figure has focus causes that figure to revert to a 'normal'
WindowStyle
property setting. This allows the user to type at the command line.
UI figures with the WindowStyle
property set to 'modal'
and the Visible
property set to 'off'
do not behave modally until MATLAB makes them visible. Therefore, you can hide a modal window for later reuse, instead of destroying it.
Modal figures do not display menu children, built-in menus, or toolbars. But, it is not an error to create menus in a modal figure or to change the WindowStyle
property setting to 'modal'
on a figure with menu children. The Menu
objects exist and the figure retains them. If you reset the UI figure WindowStyle
property to 'normal'
, the menus display.