MATLAB Function Reference | Search  Help Desk |
Text Properties |
BusyAction
cancel | {queue}
Callback routine interruption. The BusyAction
property enables you to control how MATLAB handles events that potentially interrupt executing callback routines. If there is a callback routine 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 owning the executing callback) 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
stringButton press callback routine. A callback routine that executes whenever you press a mouse button while the pointer is over the Text object. 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.
Children
matrix (read only)The empty matrix; Text objects have no children.
Clipping
on | {off}
Clipping mode. When Clipping
is on
, MATLAB does not display any portion of the Text that is outside the Axes.
Color
ColorSpec
Text color. A three-element RGB vector or one of MATLAB 's predefined names, specifying the Text color. The default value for Color
is white. See ColorSpec
for more information on specifying color.
CreateFcn
stringCallback routine executed during object creation. This property defines a callback routine that executes when MATLAB creates a Text object. You must define this property as a default value for Text. For example, the statement,
set(0,'DefaultTextCreateFcn',... 'set(gcf,''Pointer'',''crosshair'')')defines a default value on the Root level that sets the Figure
Pointer
property to a crosshair whenever you create a Text object. MATLAB executes this routine after setting all Text properties. Setting this property on an existing Text object has no effect.
The handle of the object whose CreateFcn is being executed is accessible only through the Root CallbackObject
property, which you can query using gcbo
.
DeleteFcn
string
Delete Text callback routine. A callback routine that executes when you delete the Text object (e.g., when you issue a delete
command or clear the Axes or Figure). MATLAB executes the routine before destroying the object's properties so these values are available to the callback routine.
CallbackObject
property, which you can query using gcbo
.
Editing
on | {off}
Enable or disable editing mode. When this property is set to the default of off
, you cannot edit the text string interactively (i.e., you must change the String
property to change the text). When this property is set to on
, MATLAB places an insert cursor at the beginning of the text string and enables editing. To apply the new text string:
Editing
property to off
String
property to contain the new text and resets the Editing
property to off
. You must reset the Editing
property to on
to again resume editing.
EraseMode
{normal} | none | xor | background
Erase mode. This property controls the technique MATLAB uses to draw and erase Text objects. Alternative erase modes are useful for creating animated sequences, where controlling the way individual object redraw is necessary to improve performance and obtain the desired effect.
normal
-- Redraw the affected region of the display, performing the three-dimensional analysis necessary to ensure that all objects are rendered correctly. This mode produces the most accurate picture, but is the slowest. The other modes are faster, but do not perform a complete redraw and are therefore less accurate.
none
-- Do not erase the Text when it is moved or destroyed. While the object is still visible on the screen after erasing with EraseMode
none
, you cannot print it because MATLAB stores no information about its former location.
xor
-- Draw and erase the Text by performing an exclusive OR (XOR) with each pixel index of the screen beneath it. When the Text is erased, it does not damage the objects beneath it. However, when Text is drawn in xor
mode, its color depends on the color of the screen beneath it and is correctly colored only when over Axes background Color
, or the Figure background Color
Color
is set to none
.
background
-- Erase the Text by drawing it in the background Color
, or the Figure background Color
Color
is set to none
. This damages objects that are behind the erased Text, but Text is always properly colored.
Printing with Non-normal Erase Modes
EraseMode
of all objects is normal
. This means graphics objects created with EraseMode
set to none
, xor
, or background
can look different on screen than on paper. On screen, MATLAB may mathematically combine layers of colors (e.g., XORing a pixel color with that of the pixel behind it) and ignore three-dimensional sorting to obtain greater rendering speed. However, these techniques are not applied to the printed output.
You can use the MATLAB capture
command or other screen capture application to create an image of a Figure containing non-normal mode objects.
Extent
position rectangle (read only)Position and size of Text. A four-element read-only vector that defines the size and position of the Text string:
[left,bottom,width,height]
If the Units
property is set to data
(the default), left
and bottom
are the x and y coordinates of the lower-left corner of the Text Extent
rectangle.
For all other values of Units
, left
and bottom
are the distance from the lower-left corner of the Axes position rectangle to the lower-left corner of the Text Extent
rectangle. width
and height
are the dimensions of the Extent
rectangle. All measurements are in units specified by the Units
property.
FontAngle
{normal} | italic | oblique
Character slant. MATLAB uses this property to select a font from those available on your particular system. Generally, setting this property to italic
or oblique
selects a slanted font.
FontName
stringFont family. A string specifying the name of the font to use for the Text object. To display and print properly, this must be a font that your system supports. The default font is Helvetica.
FontSize
size in FontUnits
Font size. An integer specifying the font size to use for Text, in units determined by the FontUnits
property. The default point size is 10 (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. Generally, setting this property to bold
or demi
causes MATLAB to use a bold font.
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 parent Axes. When you resize the Axes, MATLAB modifies the screen FontSize
accordingly. pixels
, inches
, centimeters
, and points
are absolute units (1 point = 1/72 inch).
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 provide 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. HitTest
determines if the Text can become the current object (as returned by the gco
command and the Figure CurrentObject
property) as a result of a mouse click on the Text. If HiTest
is off
, clicking on the Text selects the object below it (which is usually the Axes containing it).
ButtonDownFcn
property) to display text at the location you click on with the mouse,
First define the callback routine,
function bd_function pt = get(gca,'CurrentPoint'); text(pt(1,1),pt(1,2),pt(1,3),... '{\fontsize{20}\oplus} The spot to label',... 'HitTest','off')Now display an Image, setting its
ButtonDownFcn
property to the callback routine:
load earth image(X,'ButtonDownFcn','bd_function'); colormap(map)When you click on the Image, MATLAB displays the text string at that location. With
HitTest
set to off
, existing text cannot intercept any subsequent button down events that occur over the text. This enables the Image's button down function to execute.
HorizontalAlignment
{left} | center | right
Horizontal alignment of Text. This property specifies the horizontal justification of the Text string. It determines where MATLAB places the string with regard to the point specified by the Position
property. The following picture illustrates the alignment options:
Extent
property for related information.
Interpreter
{tex} | none
Interpret Tex instructions. This property controls whether MATLAB interprets certain characters in the String
property as Tex instructions (default) or displays all characters literally. See the String
property for a list of support Tex instructions.
Interruptible
{on} | off
Callback routine interruption mode. The Interruptible
property controls whether a Text callback routine can be interrupted by subsequently invoked callback routines. Text objects have four properties that define callback routines: ButtonDownFcn
, CreateFcn
, and DeleteFcn
. See the BusyAction
property for information on how MATLAB executes callback routines.
Parent
handle Text object's parent. The handle of the Text object's parent object. The parent of a Text object is the Axes in which it is displayed. You can move a Text object to another Axes by setting this property to the handle of the new parent.
Position
[x,y,[z]]
Location of Text. A two- or three-element vector, [x y [z]]
, that specifies the location of the text in three dimensions. If you omit the z
value, it defaults to 0. All measurements are in units specified by the Units
property. Initial value is [0 0 0]
.
Rotation
scalar (default = 0)Text orientation. This property determines the orientation of the Text string. Specify values of rotation in degrees (positive angles cause counterclockwise rotation).
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
Objects 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.
String
stringThe Text string. Specify this property as a quoted string for single-line strings, or as a cell array of strings or a padded string matrix for multiline strings. MATLAB displays this string at the specified location. Vertical slash characters are not interpreted as linebreaks in Text strings, and are drawn as part of the Text string. See the "Remarks" section for more information.
When the TextInterpreter
property is Tex
(the default), you can use a subset of TeX commands embedded in the string to produce special characters such as Greek letters and mathematical symbols. The following table lists these characters and the character sequence used to define them.\fontname
in combination with one of the other modifiers:
\bf
- bold font
\it
- italics font
\sl
- oblique font (rarely available)
\rm
- normal font
\fontname{
fontname}
- specify the name of the font family to use.
\fontsize{
fontsize}
- specify the font size in FontUnits
.
_
" and the superscript character "^
" modify the character or substring defined in braces immediately following.
To print the special characters used to define the Tex strings when Interpreter
is Tex
, prefix them with the backslash "\" character: \\, \{, \} \_, \^.
See the "Example" section for more information.
When Interpreter
is none
, no characters in the String
are interpreted, and all are displayed when the text is drawn.
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.
Type
string (read only)
Class of graphics object. For Text objects, Type
is always the string 'text'
.
Units
pixels | normalized | inches |
centimeters | points | {data}
Units of measurement. This property specifies the units MATLAB uses to interpret the Extent
and Position
properties. All units are measured from the lower-left corner of the Axes plotbox. Normalized
units map the lower-left corner of the rectangle defined by the Axes 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). data
refers to the data units of the parent Axes.
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 Text object. MATLAB does not use this data, but you can access it using set
and get
.
UIContextMenu
handle of a uicontextmenu object
Associate a context menu with the Text. Assign this property the handle of a Uicontextmenu object created in the same Figure as the Text. Use the uicontextmenu
function to create the context menu. MATLAB displays the context menu whenever you right-click over the Text (Control-click on Macintosh systems)
VerticalAlignment
top | cap | {middle} | baseline |
bottom
Vertical alignment of Text. This property specifies the vertical justification of the text string. It determines where MATLAB places the string with regard to the value of the Position
property. The possible values mean:
top
- Place the top of the string's Extent
rectangle at the specified y-position.
cap
- Place the string so that the top of a capital letter is at the specified y-position.
middle
- Place the middle of the string at specified y-position.
baseline
- Place font baseline at the specified y-position.
bottom
- Place the bottom of the string's Extent
rectangle at the specified y-position.
Visible
{on} | off
Text visibility. By default, all Text is visible. When set to off
, the Text is not visible, but still exists and you can query and set its properties.