command (MEL/Python)
|
MGPickerMenuItem
|
Go to: Synopsis. MEL examples. Python examples.
Synopsis
MGPickerMenuItem (menuItemIDString, [addSubMenuItem=(string, string, string, string, string)], [command=boolean], [commandType=string], [divider=boolean], [dividerLabel=string], [exist=boolean], [image=string], [insertSubMenuItem=(int, string, string, string, string, string)], [label=string], [longDivider=boolean], [numberOfSubItems=boolean],[parent=string],[radialPosition=string], [subItemArray=boolean], [subMenu=boolean], [subMenuItem=int], [view=string])
MGPickerMenuItem is NOT undoable, queryable, and editable.
This command create / queries / edits picker menu.
You always need to specify the picker menu id string to query / edit it.
In create mode, it will add a picker menu item for the parent menu / menuitem specified by -parent flag.
A picker menu item id string is something like:
commandButton1.rightmenu[0] //The first menu item in right click menu for the picker item of id "commandButton1"
selectButton1.leftmenu[1][3] //The 4th sub menu item in second menuitem in left click menu for the picker item of id "selectButton1"
For now in picker & in API, only one level of sub menu supported.
Long name (short name)
|
Argument types
|
Properties
|
-addSubMenuItem(-asi)
|
string string string script string
|
![create create](create.gif) ![edit edit](edit.gif)
|
|
Add a sub menu item to current menu item. If current menu item is already a sub menu item, it will do nothing and return empty id string, since MGPicker only support one level of sub-menu.
Specify label, icon path, command type ("mel" or "python"), command and the radial position for marking menu position ("N", "NW", "W", "SW", "S", "SE", "E" or "NE").
* Keep in mind that, if this flag is used in create mode, it will still return the added sub-menu item id instead of current menu item id.
* Also if current menu item is already a sub menu item, this flag won't work and just return empty id.
|
|
-command(-c)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The command of menu item.
|
|
-commandType(-ct)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The command type of menu item: "mel" or "python".
|
|
-divider(-d)
|
boolean
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The menu item is a separator or not.
|
|
-deleteAllSubItems(-dai)
|
|
![create create](create.gif) ![edit edit](edit.gif)
|
|
Delete all sub menu items of current menu item.
|
|
-dividerLabel(-dl)
|
boolean
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The divider label of current menu item. Only shown when menu item is a separator (dividier=True).
|
|
-exist(-ex)
|
|
![query query](query.gif)
|
|
This is a query only flag that can be used to query for the existence of a specific picker menu item.
|
|
-image(-i)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The icon path for the menu item.
|
|
-insertSubMenuItem(-isi)
|
int string string string script string
|
![create create](create.gif) ![edit edit](edit.gif)
|
|
Insert a sub-menu item to current picker menu item at certain index. Specify index small than 0 will just prepend sub-menu item at first index, index larger than last item index will just append sub-menu item.
Specify index, label, icon path, command type ("mel" or "python"), command and the radial position for marking menu position ("N", "NW", "W", "SW", "S", "SE", "E" or "NE").
* Keep in mind that, if this flag is used in create mode, it will still return the inserted sub-menu item id instead of current menu item id.
|
|
-label(-l)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The label string of the menu item.
|
|
-longDivider(-ld)
|
boolean
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
Whether or not it should be a long divider if the menu item is a separator (dividier=True).
|
|
-numberOfSubItems(-nsi)
|
|
![query query](query.gif)
|
|
The number of sub menu items.
|
|
-parent(-p)
|
string
|
![create create](create.gif) ![query query](query.gif)
|
|
In query mode, it returns the picker menu / menu item id this menu item belong to. In create mode, this is a must have flag, to specify for which menu / menu item we wanna add a menu item.
|
|
-radialPosition(-rp)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
The radial position for the menu item: "N", "NW", "W", "SW", "S", "SE", "E" or "NE". You still need to turn on the markingMenu flag for the menu to make it take effect.
|
|
-subItemArray(-sia)
|
|
![query query](query.gif)
|
|
Return list of sub menu item id string array.
|
|
-subMenu(-sm)
|
boolean
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
Decide current menu item should be a sub menu that can contain sub-menu items. If current menu item is already a sub-menu item, this flag takes no effect.
|
|
-subMenuItem(-smi)
|
int
|
![query query](query.gif)
|
|
This is a query only flag, for retrieving the sub menu item id string at specific index.
|
|
-view(-v)
|
string
|
![create create](create.gif) ![query query](query.gif) ![edit edit](edit.gif)
|
|
Specify which picker view we wanna create / edit / query the picker menu item.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can be used more than once in a command.
|
MEL examples
// You must make sure the picker item: commandButton1 is already in scene in order to test these codes.
// To form a picker menu id, use pickerItemId.leftmenu / pickerItemId.rightmenu
string $cmdButton = "commandButton1";
string $rightMenu = `MGPickerMenu -p $cmdButton -m "rightmenu"`; //This just retrieves the id "commandButton1.rightmenu" instead of creating it.
// We get a menu item id via -addMenuItem or -insertMenuItem flag of MGPickerMenu command:
string $menuItem0 = `MGPickerMenu -e -addMenuItem "First Menu Item" "/path/to/icon0.png" "mel" "print \"It works!\"" "N" $rightMenu`;
// We can add a menu item using MGPickerMenuItem command:
string $menuItem1 = `MGPickerMenuItem -parent $rightMenu
-label "Second Menu Item"
-image "/path/to/icon1.png"
-commandType "mel"
-command "print \"The MGPickerMenuItem in create mode works !\""
-radialPosition "N"`;
// We can also make a menu item a sub menu:
MGPickerMenuItem -e -subMenu 1 $menuItem0;
// Like we did above, add submenu items:
string $subMenuItem1 = `MGPickerMenuItem -e -addSubMenuItem "First SubMenu Item" "/path/to/icon.png" "python" "print 'Sub menu item works!'" "" $menuItem0`;
// We can also add a sub-menu item using MGPickerMenuItem command:
string $subMenuItem2 = `MGPickerMenuItem -parent $menuItem0
-label "Second SubMenu Item"
-image "/path/to/icon.png"
-commandType "python"
-command "print 'The MGPickerMenuItem in create mode also works for submenu item!'"`;
Python examples
from mgpicker import mgp
# You must make sure the picker item: commandButton1 is already in scene in order to test these codes.
# To form a picker menu id, use pickerItemId.leftmenu / pickerItemId.rightmenu
cmdButton = 'commandButton1'
rightMenu = mgp.MGPickerMenu(p=cmdButton, mode='rightmenu') # This just retrieves the id "commandButton1.rightmenu" instead of creating it.
# We get a menu item id via -addMenuItem or -insertMenuItem flag of MGPickerMenu command:
menuItem0 = mgp.MGPickerMenu(rightMenu, e=True, addMenuItem=('First Menu Item', '/path/to/icon0.png', 'mel', 'print "It works!"', 'N'))
# We can add a menu item using MGPickerMenuItem command:
menuItem1 = mgp.MGPickerMenuItem(parent=rightMenu,
label='Second Menu Item',
image='/path/to/icon1.png',
commandType='mel',
command='print "The MGPickerMenuItem in create mode works !"')
# We can also make a menu item a sub menu:
mgp.MGPickerMenuItem(menuItem0, e=True, subMenu=True)
# Like we did above, add submenu items:
subMenuItem1 = mgp.MGPickerMenuItem(menuItem0, e=True, addSubMenuItem=('First SubMenu Item', '/path/to/icon0.png', 'mel', 'print "Sub menu works!"', ''))
# We can also add a sub-menu item using MGPickerMenuItem command:
subMenuItem2 = mgp.MGPickerMenuItem(parent=menuItem0,
label='Second SubMenu Item',
image='/path/to/icon.png',
commandType='python',
command="print 'The MGPickerMenuItem in create mode also works for submenu item!'")
|