MATLAB Function Reference | Search  Help Desk |
uicontrol Properties |
set(0,'DefaultUicontrolProperty',PropertyValue...)
set(gcf,'DefaultUicontrolProperty',Property
Value...)
where Property
is the name of the Uicontrol property whose default value you want to set and PropertyValue
is the value you are specifying. Use set
and get
to access Uicontrol properties.
Curly braces { } enclose the default value.
BackgroundColor
ColorSpec
Object background color. The color used to fill the rectangle defined by the Uicontrol. Specify a color using a three-element RGB vector or one of MATLAB's predefined names. The default color is light gray. See ColorSpec
for more information on specifying color.
BusyAction
cancel | {queue}
Callback routine interruption. The BusyAction
property enables you to control how MATLAB handles events that potentially interrupt executing callback routines. If a callback routine is executing, subsequently invoked callback routines always attempt to interrupt it. If the Interruptible
property of the object whose callback is executing is set to on
(the default), then interruption occurs at the next point where the event queue is processed. If the Interruptible
property is off
, the BusyAction
property of the object whose callback is executing determines how MATLAB handles the event. The choices are:
cancel
- discard the event that attempted to execute a second callback routine.
queue
- queue the event that attempted to execute a second callback routine until the current callback finishes.
ButtonDownFcn
string
Button press callback routine. A callback routine that executes whenever you press a mouse button while the pointer is in a five-pixel wide border around the Uicontrol. When the Uicontrol's Enable
property is set to inactive
or off
, the ButtonDownFcn
executes when you click the mouse in the five-pixel border or on the control itself. This is useful for implementing actions to interactively modify control object properties, such as size and position, when they are clicked on (using selectmoveresize, for example).
Callback
property defines the callback routine that executes when you activate the enabled Uicontrol (e.g., click on a push button).
Callback
stringControl action. A routine that executes whenever you activate the Uicontrol object (e.g., when you click on a push button or move a slider). Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace. Note that callback routines defined for frames and static text do not execute because no action is associated with these objects.
CData
matrixTruecolor image displayed on control. A three-dimensional matrix of RGB values that defines a truecolor image displayed on either a push button or toggle button. Each value must be between 0.0 and 1.0. More information about this property.
Children
matrixThe empty matrix; Uicontrol objects have no children.
Clipping
{on} | off
This property has no effect on Uicontrols.
CreateFcn
stringCallback routine executed during object creation. This property defines a callback routine that executes when MATLAB creates a Uicontrol object. You must define this property as a default value for Uicontrols. For example, this statement:
set(0,'DefaultUicontrolCreateFcn',... 'set(gcf,''IntegerHandle'',''off'')')defines a default value on the Root level that sets the Figure
IntegerHandle
property to off
whenever you create a Uicontrol object. MATLAB executes this routine after setting all property values for the Uicontrol. Setting this property on an existing Uicontrol object has no effect.
The handle of the object whose CreateFcn is being executed is accessible only through the Root CallbackObject property, which can be queried using gcbo
.
DeleteFcn
string
Delete Uicontrol callback routine. A callback routine that executes when you delete the Uicontrol object (e.g., when you issue a delete
command or clear the Figure containing the Uicontrol). MATLAB executes the routine before destroying the object's properties so these values are available to the callback routine.
gcbo
.
Enable
{on} | inactive | off
Enable or disable the Uicontrol. This property controls how Uicontrols respond to mouse button clicks.
on
- The Uicontrol is operational. When you activate the Uicontrol (generally by clicking on it) MATLAB executes the callback routine defined by the Callback
property. When you click the mouse within a 5-pixel border outside the Uicontrol, MATLAB executes the callback routine defined by the ButtonDownFcn
.
inactive
- The Uicontrol is not operational, but it is not dimmed (i.e., it looks the same as when Enable
is on
). MATLAB executes the ButtonDownFcn
if you click the mouse on or within a 5-pixel border around the Uicontrol, but does not execute the Callback routine.
off
- The Uicontrol does not respond visually to mouse actions, does not execute its Callback routine, and its label (string
property) is grayed out. MATLAB executes the ButtonDownFcn
if you click the mouse on or within a 5-pixel border around the Uicontrol.
inactive
or off
enables you to implement object "dragging" via the ButtonDownFcn
callback routine.
Extent
position rectangle (read only)Size of Uicontrol character string. A four-element vector that defines the size and position of the character string used to label the Uicontrol. It has the form:
[0,0,width,height]
The first two elements are always zero. width
and height
are the dimensions of the rectangle. All measurements are in units specified by the Units
property.
Since the Extent
property is defined in the same units as the Uicontrol itself, you can use this property to determine proper sizing for the Uicontrol with regard to its label. Do this by
String
property and selecting the font using the relevant properties.
Extent
property.
width
and height
of the Position
property to be somewhat larger than the width
and height
of the Extent
.
Extent
rectangle encompasses all the lines of text. For single line strings, the Extent is returned as a single line, even if the string wraps when displayed on the control.
FontAngle
{normal} | italic | oblique
Character slant. MATLAB uses this property to select a font from those available on your particular system. Setting this property to italic
or oblique
selects a slanted version of the font, when it is available on your system.
FontName
stringFont family. The name of the font in which to display the String. To display and print properly, this must be a font that your system supports. The default font is system dependent.
FontSize
size in FontUnits
Font size. A number specifying the size of the font in which to display the String, in units determined by the FontUnits
property. The default point size is system dependent.
FontUnits
{points} | normalized | inches |
centimeters | pixels
Font size units. MATLAB uses this property to determine the units used by the FontSize
property. Normalized
units interpret FontSize
as a fraction of the height of the Uicontrol. When you resize the Uicontrol, MATLAB modifies the screen FontSize
accordingly. pixels
, inches
, centimeters
, and points
are absolute units (1 point = 1/72 inch).
FontWeight
light | {normal} | demi | bold
Weight of Text characters. MATLAB uses this property to select a font from those available on your particular system. Setting this property to bold
causes MATLAB to use a bold version of the font, when it is available on your system.
ForegroundColor
ColorSpec
Color of text. This property determines the color of the text defined for the String
property (the Uicontrol label). Specify a color using a three-element RGB vector or one of MATLAB 's predefined names. The default text color is black. See ColorSpec
for more information on specifying color.
HandleVisibility
{on} | callback | off
Control access to object's handle by command-line users and GUIs. This property determines when an object's handle is visible in its parent's list of children. HandleVisibility
is useful for preventing command-line users from accidentally drawing into or deleting a Figure that contains only user interface devices (such as a dialog box).
HandleVisibility
is on
.
Setting HandleVisibility
to callback
causes handles to be visible from within callback routines or functions invoked by callback routines, but not from within functions invoked from the command line. This provides a means to protect GUIs from command-line users, while allowing callback routines to have complete access to object handles.
Setting HandleVisibility
to off
makes handles invisible at all times. This may be necessary when a callback routine invokes a function that might potentially damage the GUI (such as evaluating a user-typed string), and so temporarily hides its own handles during the execution of that function.
When a handle is not visible in its parent's list of children, it cannot be returned by functions that obtain handles by searching the object hierarchy or querying handle properties. This includes get
, findobj
, gca
, gcf, gco
, newplot
, cla
, clf
, and close
.
When a handle's visibility is restricted using callback
or off
, the object's handle does not appear in its parent's Children
property, Figures do not appear in the Root's CurrentFigure
property, objects do not appear in the Root's CallbackObject property or in the Figure's CurrentObject property, and Axes do not appear in their parent's CurrentAxes
property.
You can set the Root ShowHiddenHandles
property to on to make all handles visible, regardless of their HandleVisibility settings (this does not affect the values of the HandleVisibility properties).
Handles that are hidden are still valid. If you know an object's handle, you can set
and get
its properties, and pass it to any function that operates on handles.
HitTest
{on} | off
Selectable by mouse click. This property has no effect on Uicontrol objects.
HorizontalAlignment
left | {center} | right
Horizontal alignment of label string. This property determines the justification of the text defined for the String
property (the Uicontrol label):
left
-- Text is left justified with respect to the Uicontrol.
center
-- Text is centered with respect to the Uicontrol.
right
-- Text is right justified with respect to the Uicontrol.
edit
and text
Uicontrols.
Interruptible
{on} | off
Callback routine interruption mode. The Interruptible
property controls whether a Uicontrol callback routine can be interrupted by subsequently invoked callback routines. By default (off
), a callback routine executes to completion before another can begin.
ButtonDownFcn
and Callback
properties are affected by the Interruptible
property. MATLAB checks for events that can interrupt a callback routine only when it encounters a drawnow
, figure
, getframe
, or pause
command in the routine.
ListboxTop
scalar
Index of top-most string displayed in list box. This property applies only to the listbox
style of Uicontrol. It specifies which string appears in the top-most position in a list box that is not large enough to display all list entries. ListboxTop
is an index into the array of strings defined by the String
property and must have a value between 1 and the number of strings. Noninteger values are fixed to the next lowest integer.
Max
scalar
Maximum value. This property specifies the largest value allowed for the Value
property. Different styles of Uicontrols interpret Max
differently:
Max
is the setting of the Value
property while the Uicontrol is in the on
position.
Max
- Min
> 1, then editable text boxes accept multiline input. If Max
- Min
<= 1, then editable text boxes accept only single line input.
Max
- Min
> 1, then list boxes allow multiple item selection. If Max
- Min
<= 1, then list boxes do not allow multiple item selection.
Max
is the setting of the Value
property while the Uicontrol is in the on
position.
Max
is the largest value you can select and must be greater than the Min
property. The default maximum is 1.
Max
is the value of the Value
property when the toggle button is selected. The default is 1.
Max
property.
Min
scalar
Minimum value. This property specifies the smallest value allowed for the Value
property. Different styles of Uicontrols interpret Min
differently:
Min
is the setting of the Value
property while the Uicontrol is in the off
position.
Max
- Min
> 1, then editable text boxes accept multiline input. If Max
- Min
<= 1, then editable text boxes accept only single line input.
Max
- Min
> 1, then list boxes allow multiple item selection. If Max
- Min
<= 1, then list boxes allow only single item selection.
Min
is the setting of the Value
property while the Uicontrol is in the off
position.
Min
is the smallest value you can select and must be less than Max
. The default minimum is 0.
Min
is the value of the Value
property when the toggle button is not selected. The default is 0.
Parent
handle Uicontrol's parent. The handle of the Uicontrol's parent object. The parent of a Uicontrol object is the Figure in which it appears. You can move a Uicontrol object to another Figure by setting this property to the handle of the new parent.
Position
position rectangle
Size and location of Uicontrol. The rectangle defined by this property specifies the size and location of the control within the Figure window. Specify Position
as
[left,bottom,width,height]
left
and bottom
are the distance from the lower-left corner of the Figure window to the lower-left corner of the Uicontrol object. width
and height
are the dimensions of the Uicontrol rectangle. All measurements are in units specified by the Units
property.
On Microsoft Windows systems, the height of pop-up menus is automatically determined by the size of the font. The value you specify for the height
of the Postion
property has no effect.
Selected
on | {off}
Is object selected. When this property is on
, MATLAB displays selection handles if the SelectionHighlight
property is also on
. You can, for example, define the ButtonDownFcn
to set this property, allowing users to select the object with the mouse.
SelectionHighlight
{on} | off
Object highlight when selected. When the Selected
property is on, MATLAB indicates the selected state by drawing four edge handles and four corner handles. When SelectionHighlight
is off
, MATLAB does not draw the handles.
SliderStep
[min_step max_step]
Slider step size. This property controls the amount the slider Value
changes when you click the mouse on the arrow button (min_step
) or on the slider trough (max_step
). Specify SliderStep
as a two-element vector; each value must be in the range [0,
1]
. The actual step size is a function of the specified SliderStep
and the total slider range (Max
- Min
). The default, [0.01 0.10]
, provides a 1 percent change for clicks on the arrow button and a 10 percent change for clicks in the trough.
uicontrol('Style','slider','Min',1,'Max',7,...
'SliderStep',[0.1 0.6])
clicking on the arrow button moves the indicator by,
0.1*(7-1) ans = 0.6000and clicking in the trough moves the indicator by,
0.6*(7-1) ans = 3.6000Note that if the specified step size moves the slider to a value outside the range, the indicator moves only to the
Max
or Min
value.
See also the Max
, Min
, and Value
properties.
String
stringUicontrol label. A string specifying the text displayed on check boxes, editable text, list boxes, pop-up menus, push buttons, radio buttons, static text, and toggle buttons.
For multiple items on a pop-up menu or a list box, items can be specified as a cell array of strings, a padded string matrix, or within a string vector separated by vertical slash (`|') characters. For multiple line editable text or static text controls, line breaks occur between each row of the string matrix, each cell of a cell array of strings, and after any\n
characters embedded in the string. Vertical slash (`|') characters are not interpreted as linebreaks, and instead show up in the text displayed in the uicontrol.
For the remaining Uicontrol objects, which display only one line of text, only the first string of a cell array of strings or of a padded string matrix is displayed; the rest are ignored. Vertical slash (`|') characters are not interpreted as linebreaks and instead show up in the text displayed in the Uicontrol.
For editable text, this property is set to the string typed in by the user.
Style
{pushbutton} | togglebutton | radiobutton |
checkbox | edit | text | slider | frame |
listbox | popupmenu
Style of Uicontrol object to create. The Style
property specifies the kind of Uicontrol to create. See the "Description" section for information on each type.
Tag
string
User-specified object label. The Tag
property provides a means to identify graphics objects with a user-specified label. This is particularly useful when constructing interactive graphics programs that would otherwise need to define object handles as global variables or pass them as arguments between callback routines. You can define Tag
as any string.
TooltipString
string
Content of tooltip for object. The TooltipString
property specifies the text of the tooltip associated with the Uicontrol. When the user moves the mouse pointer over the control and leaves it there, the tooltip is displayed. More information about this property.
Type
string (read only)
Class of graphics object. For Uicontrol objects, Type
is always the string 'uicontrol'
.
UIContextMenu
handle
Associate a context menu with Uicontrol. Assign this property the handle of a Uicontextmenu object. MATLAB displays the context menu whenever you right-click over the Uicontrol (Ctrl-click on Macintosh systems). Use the uicontextmenu
function to create the context menu. More information about this property.
Units
{pixels} | normalized | inches |
centimeters | points | characters
Units of measurement. The units MATLAB uses to interpret the Extent
and Position
properties. All units are measured from the lower-left corner of the Figure window. Normalized
units map the lower-left corner of the Figure window to (0,0) and the upper-right corner to (1.0,1.0). pixels
, inches
, centimeters
, and points
are absolute units (1 point = 1/72 inch). Character
units are characters using the default system font; the width of one character is the width of the letter x, the height of one character is the distance between the baselines of two lines of text. More information about character units.
Units
, it is good practice to return it to its default value after completing your computation so as not to affect other functions that assume Units
is set to the default value.
UserData
matrix
User-specified data. Any data you want to associate with the Uicontrol object. MATLAB does not use this data, but you can access it using set
and get
.
Value
scalar or vectorCurrent value of Uicontrol. The Uicontrol style determines the possible values this property can have:
Value
to Max
when they are on (when the indicator is filled) and Min
when off (not filled).
Value
to a vector of indices corresponding to the selected list entries, where 1 corresponds to the first item in the list.
Value
to the index of the item selected, where 1 corresponds to the first item on the menu. The "Examples" section shows how to use the Value
property to determine which item has been selected.
Value
to Max
when they are on (when the indicator is filled) and Min
when off (not filled).
Value
to the number indicated by the slider bar, which is within the range established by Min
and Max
.
Value
to Max
when they are down (selected) and Min
when up (not selected).
Value
property either interactively with the mouse or through a call to the set
function. The display reflects changes made to Value
.
Visible
{on} | off
Uicontrol visibility. By default, all Uicontrols are visible. When set to off
, the Uicontrol is not visible, but still exists and you can query and set its properties.