Control progress dialog box appearance and behavior
Progress dialog boxes indicate that an operation is in progress by displaying
an animated progress bar. The uiprogressdlg
function creates a progress dialog box and sets any
required properties before displaying it. By changing property values of a progress
dialog box, you can modify certain aspects of its appearance and behavior. Use dot
notation to refer to a specific object and property:
fig = uifigure; d = uiprogressdlg(fig); d.Value = .25;
Message
— message''
(default) | character vector | cell array of character vectors | string arrayMessage, specified as a character vector, cell array of character vectors, or string array. The message displays within the dialog box, above the progress bar.
To display multiple lines of text, specify a cell array of character vectors or a
string array. Each element in the array corresponds to a line of text. Hard breaks
within each element, such as '\n'
, create additional lines of
text.
Example: d = uiprogressdlg(uifigure,'Message','Calculating result.');
Title
— Title''
(default) | character vector | string scalarTitle, specified as a character vector or a string scalar. The title displays in the title bar of the dialog box.
Example: d = uiprogressdlg(uifigure,'Title','Calculating');
Icon
— Icon''
(default) | predefined icon | custom iconIcon, specified as a predefined icon or a custom icon.
This table lists the values for the predefined icons.
Value | Icon |
---|---|
'' (default) | No icon displays. |
'question' |
|
'info' |
|
'success' |
|
'warning' |
|
'error' |
|
Specify a custom icon as one of these values:
A character vector or string scalar 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.
Value
— Fraction complete0
(default) | number between 0
and 1
Fraction complete, specified as a number between 0
and
1
. The progress bar reaches its full length when the value is
1
. Change Value
at different points in your
code to provide a visual indication of progress in the running app.
Data Types: double
ShowPercentage
— Show percentage'off'
(default) | on/off logical valueShow percentage, specified as 'off'
or
'on'
, or as numeric or logical 1
(true
) or 0
(false
). A value of 'on'
is
equivalent to true
, and 'off'
is
equivalent to false
. Thus, you can use the value of this
property as a logical value. The value is stored as an on/off logical value
of type matlab.lang.OnOffSwitchState
.
Set this property to 'on'
to display the fraction
complete as a percentage in the dialog box.
Indeterminate
— Indeterminate progress'off'
(default) | on/off logical valueIndeterminate progress, specified as 'off'
or 'on'
, or
as numeric or logical 1
(true
) or 0
(false
). A value of
'on'
is equivalent to
true
, and
'off'
is equivalent to
false
. Thus, you can use the
value of this property as a logical value. The value is stored
as an on/off logical value of type matlab.lang.OnOffSwitchState
.
Set this property to 'on'
to provide an animated
bar without any specific progress information. This animation is
useful when you do not know how long a calculation will
take.
To prevent indeterminate progress bars from displaying indefinitely, call the close
function after completing your calculations.
Cancelable
— Allow cancellation'off'
(default) | on/off logical valueAllow cancellation, specified as 'off'
or 'on'
, or as
numeric or logical 1
(true
) or
0
(false
). A value of 'on'
is equivalent to true
, and 'off'
is equivalent to
false
. Thus, you can use the value of this property as a logical
value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState
.
A value of 'on'
displays a cancel button in the dialog box. You
can customize the button label by specifying the CancelText
property.
When you allow cancellation, you must check the value of the CancelRequested
property, and call the close
function when the value is true
. Otherwise, the dialog box displays indefinitely.
CancelText
— Cancel button text'Cancel'
(default) | character vector | string scalarCancel button text, specified as a character vector or string scalar. This
property has an effect only when the Cancelable
property is set to 'on'
.
Example: d =
uiprogressdlg(uifigure,'Cancelable','on','CancelText','Stop')
CancelRequested
— Cancel requestedtrue
| false
Cancel requested, specified as true
or
false
. Use this property when
Cancelable
is 'on'
, and you want
to know whether the user clicked the cancel button. This property is
false
until the user clicks the
cancel button, then the value changes to true
.