I was experimenting with the onKeyEvent(), following the Python States documentation, but I'm facing a couple of issues.
If I press a key NOT in the group, the ELSE statement is executed, but I'm getting anyway the aforementioned output error in the console, which is quite annonying.
If I press the ‘s’ key, instead Houdini would exit the viewer state and switch to the Selection State, which is understandable, being ‘s’ the hotkey for that, BUT the IF statement is not getting evaluated. So you can't know if an already assigned hotkey is being pressed in your custom node viewer state.
defonKeyEvent(self,kwargs):ui_event=kwargs['ui_event']self.key_pressed=ui_event.device().keyString()ifself.key_pressedin('a','s','shift a','ctrl g'):# returns True to consume the eventprint('key pressed')returnTrueelse:print('No')
The issue #1 has been fixed in 17.5, you probably just need to get an updated build.
Regarding case #2, Houdini will intercept the ‘S’ key before onKeyEvent can even see it, unfortunately the key is not overridable. The select state will be run as volatile and your state will get active again once you've done a selection. At this point the onSelection callback should be called if one is defined.
Regarding 2), I just needed to call a custom function during the python state when ‘S’ is pressed. I've found that I can temporarily clear the ‘S’ assignment during my python state (and reload it on exit)
Reviving an old post here but I think this is related to my question... So when I right click on a geo, there's a default context menu. Is there a way to deactivate that so i can do custom RMB events on actual geometry? I don't have any custom context menu. When I RMB on empty viewport space it logs in the RMB event properly though, so I know it's working the way it's supposed to.