Creates a context menu that is displayed with a right-click for a figure, uitab, or select uicontrol objects.

## Syntax

h = uicontextmenu(parent, property, value, ...)

## Inputs

parent
Handle of a figure, uitab, or uicontrol objects of styles 'pushbutton', 'togglebutton', and 'text'.
Type: double | integer
property, value
'createfcn'
Function that is triggered when h is created. If value is a function handle, it must be a function that takes at least two arguments. The first argument is the handle of the uicontrol. The second argument is the event data to the uicontrol, which is ignored for createfcn. If value is a string, it must represent a function handle or a function name. If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to callback function in the additional elements. After it is executed, createfcn cannot be interrupted.
Type: cell | functionhandle | string
'deletefcn'
Function that is triggered when h is deleted. If value is a function handle, it must be a function that takes at least two arguments. The first argument is the handle of the uicontrol. The second argument is the event data to the uicontrol, which is ignored for createfcn. If value is a string, it must represent a function handle or a function name. If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to callback function in the additional elements. After it is executed, createfcn cannot be interrupted.
Type: cell | functionhandle | string
'enable'
Specifies if h is enabled. Valid values are 'on'(default) and 'off'.
Type: string
'tag'
User-defined string to tag graphical control objects.
Type: string
'userdata'
User defined numerical data.
Type: complex | mtx | scalar
'visible'
Specifies if h is visible. Valid values are 'on'(default) and 'off'.
Type: string

h

## Examples

Create a context menu for a figure:
% Callback for menu1
function outfunc1 = func1(h,callstate)
end

function outfunc2 = func2(h,callstate,argument1,argument2)
end

f = figure;

% Creates individual context menu items
menu2 = uicontextmenuitem(c, 'label', 'Do something else', 'callback', {@func2, 'foo', 1});
Create a context menu for a button:
% Callback for menu1
function outfunc1 = func1(h,callstate)
end

menu2 = uicontextmenuitem(c, 'label', 'Do something else', 'callback', {@func2, 'foo', 1});