MATLAB Function Reference Previous page   Next Page
uicontrol

Create user interface control object

Syntax

Description

uicontrol creates a uicontrol graphics objects (user interface controls), which you use to implement graphical user interfaces.

handle = uicontrol('PropertyName',PropertyValue,...) creates a uicontrol and assigns the specified properties and values to it. It assigns the default values to any properties you do not specify. The default uicontrol style is a pushbutton. The default parent is the current figure. See Properties for information about these and other properties.

handle = uicontrol(parent,'PropertyName',PropertyValue,...) creates a uicontrol in the object specified by the handle, parent. If you also specify a different value for the Parent property, the value of the Parent property takes precedence. parent can be the handle of a figure, uipanel, or uibuttongroup.

handle = uicontrol creates a pushbutton in the current figure. The uicontrol function assigns all properties their default values.

uicontrol(uich) gives focus to the uicontrol specified by the handle, uich.

When selected, most uicontrol objects perform a predefined action. MATLAB supports numerous styles of uicontrols, each suited for a different purpose:

For information on using these uicontrols within GUIDE, the MATLAB GUI development environment, see

Specifying the Uicontrol Style

To create a specific type of uicontrol, set the Style property as one of the following strings:

Remarks

Properties

This table lists all properties useful for uicontrol objects, grouping them by function. Each property name acts as a link to a description of the property.

Property Name
Property Description
Property Value
Controlling Style and Appearance
BackgroundColor
Object background color
Value: ColorSpec
Default: system dependent
CData
Truecolor image displayed on the control
Value: matrix
ForegroundColor
Color of text
Value: ColorSpec
Default: [0 0 0]
SelectionHighlight
Object highlighted when selected
Value: on, off
Default: on
String
Uicontrol label, also list box and pop-up menu items
Value: string
Visible
Uicontrol visibility
Value: on, off
Default: on
General Information About the Object
Children
Uicontrol objects have no children

Enable
Enable or disable the uicontrol
Value: on, inactive, off
Default: on
Parent
Uicontrol object's parent
Value: figure, uipanel, or uibuttongroup handle
Selected
Whether object is selected
Value: on, off
Default: off
SliderStep
Slider step size
Value: two-element vector
Default: [0.01 0.1]
Style
Type of uicontrol object
Value: pushbutton, togglebutton, radiobutton, checkbox, edit, text, slider, listbox, popupmenu
Default: pushbutton
Tag
User-specified object identifier
Value: string
TooltipString
Content of object's tooltip
Value: string
Type
Class of graphics object
Value: string (read-only)
Default: uicontrol
UserData
User-specified data
Value: matrix
Controlling the Object Position
Position
Size and location of uicontrol object
Value: position rectangle
Default: [20 20 60 20]
Units
Units to interpret position vector
Value: pixels, normalized, inches, centimeters, points, characters
Default: pixels
Controlling Fonts and Labels
FontAngle
Character slant
Value: normal, italic, oblique
Default: normal
FontName
Font family
Value: string
Default: system dependent
FontSize
Font size
Value: size in FontUnits
Default: system dependent
FontUnits
Font size units
Value: points, normalized, inches, centimeters, pixels
Default: points
FontWeight
Weight of text characters
Value: light, normal, demi, bold
Default: normal
HorizontalAlignment
Alignment of label string
Value: left, center, right
Default: depends on uicontrol object
String
Uicontrol object label, also list box and pop-up menu items
Value: string
Controlling Callback Routine Execution
BusyAction
Callback routine interruption
Value: cancel, queue
Default: queue
ButtonDownFcn
Button-press callback routine
Value: string or function handle
Callback
Control action
Value: string or function handle
CreateFcn
Callback routine executed during object creation
Value: string or function handle
DeleteFcn
Callback routine executed during object deletion
Value: string or function handle
Interruptible
Callback routine interruption mode
Value: on, off
Default: on
KeyPressFcn
Key press callback routine
Value: string or function handle
UIContextMenu
Uicontextmenu object associated with the uicontrol
Value: handle
Information About the Current State
ListboxTop
Index of top-most string displayed in list box
Value: scalar
Default: [1]
Max
Maximum value (depends on uicontrol object)
Value: scalar
Default: object dependent
Min
Minimum value (depends on uicontrol object)
Value: scalar
Default: object dependent
Value
Current value of uicontrol object
Value: scalar or vector
Default: object dependent
Controlling Access to Objects
HandleVisibility
Whether handle is accessible from command line and GUIs
Value: on, callback, off
Default: on
HitTest
Whether selectable by mouse click
Value: on, off
Default: on

Examples

Example 1. The following statement creates a push button that clears the current axes when pressed.

This statement gives focus to the pushbutton.

Example 2. You can create a uicontrol object that changes figure colormaps by specifying a pop-up menu and supplying an M-file name as the object's Callback:

The above call to uicontrol defines four individual choices in the menu: hsv, hot, cool, and gray. You specify these choices with the String property, separating the choices with the "|" character.

The Callback, in this case setmap, is the name of an M-file that defines a more complicated set of instructions than a single MATLAB command. setmap contains these statements:

The Value property contains a number that indicates the selected choice. The choices are numbered sequentially from one to four. The setmap M-file can get and then test the contents of the Value property to determine what action to take.

See Also

textwrap, uibuttongroup, uimenu, uipanel


Previous page  Uicontextmenu Properties Uicontrol Properties Next page

© 1994-2005 The MathWorks, Inc.