Custom Popup Menu

   3368   5   3
User Avatar
Member
129 posts
Joined: Oct. 2015
Offline
Hi !

Is there a way to make a custom popup menu (like the one on the “tab” key) to put my own script/command/asset and don't “polute” the factory one ?

Like this in Sofimage : http://rray.de/xsi/xpop/ [rray.de]

Thanks.
User Avatar
Staff
450 posts
Joined: April 2014
Offline
It is certainly possible.

Look at the following thread where a user created a really impressive modeling toolbox.
https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=41478&start=50&postdays=0&postorder=asc&highlight= [sidefx.com]

Houdini ships with PySide built-in, so you can install a global Qt event filter and react to mouse clicks from Python.

https://srinikom.github.io/pyside-docs/PySide/QtCore/QObject.html#PySide.QtCore.PySide.QtCore.QObject.installEventFilter [srinikom.github.io]

You would need to do something like:

class KeyPressEater(QObject):
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress:
print “Ate key press”, event.key()
return True
else:
# standard event processing
return QObject.eventFilter(self, obj, event)

keyPressEater = KeyPressEater(self)
hou.ui.mainQtWindow().installEventFilter(keyPressEater)


This code is untested and if it works, it will capture all the keyPress event leaving Houdini in a zombie state. Once you have the filter up and running and can hook any PySide code you want to it.
User Avatar
Member
129 posts
Joined: Oct. 2015
Offline
Hello Guillaume,

That's seems to be good, I will look at this !
Thanks.
User Avatar
Member
678 posts
Joined: July 2005
Offline
:evil:
User Avatar
Member
129 posts
Joined: Oct. 2015
Offline
Hello, Here we have !
odforce post [forums.odforce.net]
User Avatar
Member
151 posts
Joined: May 2015
Offline
Awesome, thanks for sharing!
  • Quick Links