(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, specified as a character vector, cell array of character vectors, or string array. The message can be any length.
Format characters such as the newline character (
are honored. Use a cell array of character vectors or a string array to
display multiple lines of text.
'Error'(default) | character vector | string scalar
Title, specified as a character vector or string scalar. Long titles are truncated and followed by ellipses. The exact length at which a title is truncated depends on your system setup.
Format characters, such as the newline (
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
'error'(default) | predefined icon | custom icon
Icon, specified as a predefined icon or a custom icon.
This table lists the values for the predefined icons. For example,
to show the check mark icon, specify the name-value pair
No icon displays.
Specify a custom icon as one of these values:
A character vector that specifies the file name of an SVG, JPEG, GIF, or PNG image that is on the MATLAB path. Alternatively, you can specify a full path to the image file.
A truecolor image array. See Image Types for more information.
Modal, specified as
A modal dialog box is one that makes the figure inaccessible until the dialog box is closed. However, it does not prevent additional dialog boxes from appearing.