Home  Previous Next

command (MEL/Python)

MGPickerMenu

Go to: MEL synopsis. Python synopsis. Return value. Flags. MEL examples. Python examples.

MEL Synopsis

MGPickerMenu [-addMenuItem] [-copyMenu] [-copyPairedMenu] [-deleteAllItems] [-exist] [-itemArray] [-insertMenuItem] [-mode] [-menuItem] [-markingMenu] [-numberOfItems] [-parent] [-useRightMenu] [-view] menuIDString

Python Synopsis

MGPickerMenu (menuIDString, [addMenuItem=(string, string, string, string, string)], [copyMenu=boolean], [copyPairedMenu=boolean], [deleteAllItems=boolean],  [exist=boolean], [itemArray=boolean], [insertMenuItem=(int, string, string, string, string, string)], [mode=string], [menuItem=int], [markingMenu=boolean],[numberOfItems=boolean],[parent=string],[useRightMenu=boolean], [view=string])

 

MGPickerMenu is NOT undoable, queryable and editable.

You don't need to create a picker menu, it is already there for each picker item, all you need is to query / edit them.

However, you can still use this command in create mode, which will just retrieve the menu id from the picker item, instead of creating them.
In "create" mode, you should specify -parent and  -mode flags, in order to retrieve the menu id.
You always need to specify the picker menu id string to query / edit it.

A picker menu id string is something like:

 commandButton1.rightmenu                //The right click menu for the picker item of id "commandButton1"

 selectButton1.leftmenu                //The left click menu for the picker item of id "selectButton1"

 

In edit / create mode, the flags that are meant to be used for editing will exclude each other, it will just execute one flag and return.

Return value

In edit mode usually it returns the menu id string or the menu item id string if it is for adding / inserting child menu item.

Flags

addMenuItem, copyMenu, copyPairedMenu, deleteAllItems, exist, itemArray, insertMenuItem, mode, menuItem, markingMenu, numberOfItems, parent, useRightMenu, view

 

Long name (short name)

Argument types

Properties

-addMenuItem(-ami)

string string string script string

createedit


This is a edit only flag that can be used to add a menu item to picker 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 menu item id instead of the menu id.

-copyMenu(-cm)

string

createedit


This is a edit only flag that can be used to copy menu data from other menu.

-copyPairedMenu(-cpm)


createedit


This is a edit only flag that can be used to copy menu data from paired menu. eg. Left click menu copy data from right click menu, right click menu copy data from left click menu.

-deleteAllItems(-dai)


createedit


This is a edit only flag, clear all menu data from a picker menu.

-exist(-ex)


query


This is a query only flag that can be used to query for the existence of a specific picker menu.

-itemArray(-ia)


query


This is a query only flag that can be used to query  the list of menu items id string array.

-insertMenuItem(-imi)

int string string string script string

createedit


This is a edit only flag that can be used to insert a menu item to picker menu at certain index. Specify index small than 0 will just prepend menu item at first index, index larger than last item index will just append 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 menu item id instead of the menu id.

-mode(-m)

string

createquery


In query mode, it returns the current menu is picker item's right clicking menu or right clicking menu. In create mode, this is a must have flag, to specify which menu we wanna retrieve. (-parent is also a must have flag in create mode)

-menuItem(-mi)

int

query


This is a query only flag, for retrieving the menu item id string at specific index.

-markingMenu(-mm)

boolean

createqueryedit


Query or set if the menu is a marking menu.

-numberOfItems(-ni)

 

query


Query the number of menu items in this menu.

-parent(-p)

string

createquery


In query mode, it returns the picker picker item  id this menu belongs to. In create mode, this is a must have flag, to specify which menu we wanna retrieve. (-mode is also a must have flag in create mode)

-useRightMenu(-urm)

boolean

createqueryedit


Decide if the left click menu use the content of right click menu.

For right click menu, in edit mode this flag has no effect, in query mode, this flag always return true.

-view(-v)

string

createqueryedit


Specify which picker view we wanna create / edit / query the picker menu.








create Flag can appear in Create mode of command

edit Flag can appear in Edit mode of command

query Flag can appear in Query mode of command

multiuse 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.
 
// Add / Insert a menu item:
string $menuItem1 = `MGPickerMenu -e -addMenuItem "First Menu Item" "/path/to/icon0.png" "mel" "print \"It works!\"" "N" $rightMenu`;
string $menuItem3 = `MGPickerMenu -e -addMenuItem "Third Menu Item" "/path/to/icon2.png" "python" "print 'It works!'" "S" $rightMenu`;
string $menuItem2 = `MGPickerMenu -e -insertMenuItem 1 "Second Menu Item" "/path/to/icon1.png" "python" "print 'It inserts!'" "E" $rightMenu`;

// Now you can test right click on commandButton1 using preview tool, see menu pops up!
 
// Let's continue to toggle on the marking menu state of the menu.
MGPickerMenu -e -markingMenu 1 $rightMenu;
// Now you can test right click on commandButton1 using preview tool, see marking menu pops up!
 

Python examples

import maya.cmds as cmd

# 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 = cmds.MGPickerMenu(p=cmdButton, mode='rightmenu') # This just retrieves the id "commandButton1.rightmenu" instead of creating it.
 
#  Add / Insert a menu item:
menuItem1 = cmds.MGPickerMenu(rightMenu, e=True, addMenuItem=('First Menu Item', '/path/to/icon0.png', 'mel', 'print "It works!"', 'N'))
menuItem3 = cmds.MGPickerMenu(rightMenu, e=True, addMenuItem=('Third Menu Item', '/path/to/icon2.png', 'python', 'print "It works!"', 'S'))
menuItem2 = cmds.MGPickerMenu(rightMenu, e=True, insertMenuItem=(1, 'Second Menu Item', '/path/to/icon1.png', 'python', 'print "It inserts!"', 'E'))

# Now you can test right click on commandButton1 using preview tool, see menu pops up!
 
# Let's continue to toggle on the marking menu state of the menu.
cmds.MGPickerMenu(rightMenu, e=True, markingMenu=True )
# Now you can test right click on commandButton1 using preview tool, see marking menu pops up!

Home Previous Next