| MATLAB Function Reference | ![]() |
Syntax
Description
uicontextmenu creates a context menu, which is a menu that appears when the user right-clicks on a graphics object.
You create context menu items using the uimenu function. Menu items appear in the order the uimenu statements appear. You associate a context menu with an object using the UIContextMenu property for the object and specifying the context menu's handle as the property value.
Properties
This table lists the properties that are useful to uicontextmenu 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 | ||
Visible |
Uicontextmenu visibility |
Value: on, offDefault: off |
Position |
Location of uicontextmenu when Visible is set to on |
Value: two-element vector Default: [0 0] |
| General Information About the Object | ||
Children |
The uimenus defined for the uicontextmenu |
Value: matrix |
Parent |
Uicontextmenu object's parent |
Value: scalar figure handle |
Tag |
User-specified object identifier |
Value: string |
Type |
Class of graphics object |
Value: string (read-only) Default: uicontrol |
UserData |
User-specified data |
Value: matrix |
| Controlling Callback Routine Execution | ||
BusyAction |
Callback routine interruption |
Value: cancel, queueDefault: queue |
Callback |
Control action |
Value: string |
CreateFcn |
Callback routine executed during object creation |
Value: string |
DeleteFcn |
Callback routine executed during object deletion |
Value: string |
Interruptible |
Callback routine interruption mode |
Value: on, offDefault: on |
| Controlling Access to Objects | ||
HandleVisibility |
Whether handle is accessible from command line and GUIs |
Value: on, callback, offDefault: on |
Example
These statements define a context menu associated with a line. When the user extend-clicks anywhere on the line, the menu appears. Menu items enable the user to change the line style.
% Define the context menu cmenu = uicontextmenu; % Define the line and associate it with the context menu hline = plot(1:10, 'UIContextMenu', cmenu); % Define callbacks for context menu items cb1 = ['set(hline, ''LineStyle'', ''--'')']; cb2 = ['set(hline, ''LineStyle'', '':'')']; cb3 = ['set(hline, ''LineStyle'', ''-'')']; % Define the context menu items item1 = uimenu(cmenu, 'Label', 'dashed', 'Callback', cb1); item2 = uimenu(cmenu, 'Label', 'dotted', 'Callback', cb2); item3 = uimenu(cmenu, 'Label', 'solid', 'Callback', cb3);
When the user extend-clicks on the line, the context menu appears, as shown in this figure:
See Also
uibuttongroup, uicontrol, uimenu, uipanel
| Uibuttongroup Properties | Uicontextmenu Properties | ![]() |
© 1994-2005 The MathWorks, Inc.