(App Designer) Display alert dialog box for UI figure window
uialert(figure, message, title)
Create a modal alert dialog box. The figure behind it is inaccessible until you close the dialog box.
fig = uifigure; uialert(fig,'File not found','Invalid File');
fig = uifigure; message = sprintf('Fire hazard! \n Consider reducing temperature.'); uialert(fig,message,'Warning',... 'Icon','warning');
figure— Figure window on which alert dialog box will display
Figure window on which alert dialog box will display, specified
Figure object returned by the
message— Text to display in the alert dialog box
The text to display in the alert dialog box, specified as a character vector or a cell array of character vectors. The message can be any length.
If you specify the message as preformatted character vector using the
sprintf function, format characters such as the
\n, are honored. For instance, you can
sprintf('first line \n second line'). A cell array of
character vectors is displayed as multiline text, where each row of the
array is one line of text.
title— Text to display at the top of the alert dialog box
'Error'(default) | character vector
The text to display at the top of the alert dialog box, specified as a character vector. Long titles are truncated and followed by ellipses. The exact length at which a title is truncated depends on your system setup.
If you specify a preformatted character array using
sprintf, then format
characters, such as the newline (
\n) character and the
carriage return character (
\r) , are replaced by spaces.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside single quotes (
' '). You can
specify several name and value pair arguments in any order as
'CloseFcn'— Alert dialog box close request function callback
''(default) | function handle | cell array | character vector
The alert dialog box close request callback function, specified as one of these values:
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector that is a valid MATLAB® expression. MATLAB evaluates this expression in the base workspace.
CloseFcn callback executes when the
app user dismisses the alert dialog box by clicking the close button
in the title bar or clicking the OK button. The
also executes when the app user closes the figure window for which
the alert dialog box displays from the MATLAB command line. You
can close a figure window from the command line using the
'Icon'— Icon for the alert dialog box
'none'| path to a SVG, JPEG, GIF, or PNG image file | m-by-n-by-3 RGB image Cdata matrix
The icon for the alert dialog box, specified as one of the values listed in this table.
Icon is .
Icon is .
Icon is .
Icon is .
No icon included in the alert dialog box.
|Path to a SVG, JPEG, GIF, or PNG image file|
Icon is the image at the specified path. Vector format files (SVG images) automatically scale to fit the dialog box best. SVG files are the preferred format to support different resolution systems (for example, high-DPI systems).
Raster image formats are displayed in their actual size up to 32 by 32 pixels. Icons that are larger than 32 by 32 pixels are scaled down. Smaller icons are displayed as-is, without scaling up.
|m-by-n-by-3 RGB image Cdata matrix|
The CData format must be a 3-D array of truecolor RGB
triplets. These values can be double-precision values between 0.0
and 1.0 or
For more information on CData, see Image Properties in the MATLAB Graphics documentation.
An image file name must refer to a file that is discoverable
by and accepted by the MATLAB
For example, the image file name must specify a name and extension
of the image file on the MATLAB path or the full path to the
'Modal'— Alert dialog box modal state
Alert dialog box modal state with respect to the specified UI
figure, specified as
A modal alert dialog box is one that makes the figure inaccessible until the alert dialog box is closed. However, it does not prevent additional dialog boxes from appearing.