Main Content

uialert

Display alert dialog box

Description

example

uialert(无花果,message,title)displays a modal dialog box in front of the specified figure window. The figure must be created with theuifigurefunction. The dialog box displays the specified message and has a title bar with the specified title. By default, the dialog box also contains an error icon and anOKbutton.

example

uialert(___,Name,Value)displays a dialog box with properties specified by one or moreName,Valuepair arguments.

Examples

collapse all

Create a modal alert dialog box. The figure behind it is inaccessible until you close the dialog box.

无花果= uifigure; uialert(fig,'File not found','Invalid File');

无花果= uifigure; message = sprintf('Fire hazard! \n Consider reducing temperature.'); uialert(fig,message,'Warning',...'Icon','warning');

Input Arguments

collapse all

目标无花果ure, specified as aFigureobject. The figure must be created with theuifigurefunction.

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 (\n) are honored. To display multiple lines of text, use a cell array of character vectors or a string array.

Example:'Invalid value'

Title, specified as a character vector or string scalar. Long titles truncate and are followed by ellipses. The exact length at which a title is truncated depends on your system setup.

Spaces replace format characters, such as the newline (\n) character.

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name andValueis the corresponding value.Namemust appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN.

Example:'Icon','warning'

The alert dialog box close request callback function, specified as one of these values:

  • Function handle.

  • 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.

TheCloseFcncallback executes when the app user dismisses the alert dialog box by clicking the close button in the title bar or clicking theOKbutton. TheCloseFcnfunction 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 theclosefunction.

Icon, specified as a predefined icon or a custom icon.

Predefined Icon

This table lists the values for the predefined icons. For example, to show the check mark icon, specify the name-value pair“图标”,“成功”.

Value Icon
'error'(default)

'warning'

'info'

'success'

''

No icon displays.

Custom Icon

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. SeeImage Typesfor more information.

Modal, specified astrueorfalse.

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.

Introduced in R2016a