in Programmer by
edited by
In MGPicker there are many places that are programable, like button right-click and left-click menus, command button's command, attribute button pre/post changed command, slider change command, etc.

But when coding in these commands, how do I know which button I am interacting with?

Like the button the menu belongs to, the command button I just clicked, etc?

I need a way to retrieve the id of the button, so I can do query/edit on the button data.

1 Answer

0 votes
by
 
Best answer

You can use this to query the current interacting picker item (button):

from maya import cmds
parentButton = cmds.MGPicker(q=True, currentItem=True)
print ("Interacting with {}".format(parentButton));

Notice that the flag belongs to MGPicker, not MGPickerView, as it is an application-level state as you can only interact with one picker button at a time.

The current item will be set when you click on a picker button, got some command triggered, or its right-click or left-click menu popup up.

...