1

I've been trying to get a right click command working on the icontextbutton in maya using python. I know there is a popup menu, which is working fine, but i dont want a popup, as it adds a second click to the workflow, rather than having a command execute on RMB press. There seems to be no doc on the subject and google isnt helping either, so i am hoping anyone may have an idea, maybe some undocumented flags I'm unaware of. So LMB should execute one command and RMB should execute another. Is there any way of doing that ?

1 Answer 1

1

I would recommend straight-up using Qt for this, instead of wrapping through Maya's Python stuff.

That said, you can achieve something mostly functional by hooking the RMB through an empty popupMenu:

import maya.cmds as cmds window = cmds.window() cmds.columnLayout(adjustableColumn=True ) cmds.iconTextButton(style='iconOnly', image1='spotlight.png', label='spotlight', command='print "left click"') cmds.popupMenu(postMenuCommand='print "right click"') cmds.showWindow(window) 

However, the focus on the open-but-invisible menu seems to make multiple clicks a bit "off" somehow, but otherwise it seems quite usable.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, the empty menu does the trick. No issues with "off" clicks so far.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.