Greetings everybody
I am wondering if it is possible to disable hotkeys while in a custom python viewer state. Here is my problem, I am trying to use the “t”, “r” and “e” onKeyEvent in my object level python viewer state, but the viewport hotkeys seem to catch them first and it switches to the translation, rotation or scaling tools. I tried with the onKeyTransitEvent and it does catch the “key down” event and I then return True to consume the key transition, but the viewport still switches to the corresponding transformation tool.
Would there be a way to use those keys or do hotkeys have priority over viewer states key events?
Thanks in advance for you help
Python Viewer State and Hotkeys
4125 14 3- Control_Vertex
- Member
- 161 posts
- Joined: 5月 2015
- Offline
- mabelzile
- スタッフ
- 444 posts
- Joined: 2月 2018
- Offline
- Control_Vertex
- Member
- 161 posts
- Joined: 5月 2015
- Offline
- Akelian
- Member
- 34 posts
- Joined: 7月 2015
- Offline
- mabelzile
- スタッフ
- 444 posts
- Joined: 2月 2018
- Offline
- wyhinton1
- Member
- 80 posts
- Joined: 2月 2020
- Offline
- artchapter
- Member
- 5 posts
- Joined: 10月 2021
- Offline
- wyhinton1
- Member
- 80 posts
- Joined: 2月 2020
- Offline
- playBlaster
- Member
- 18 posts
- Joined: 11月 2018
- Offline
this is now possible. in your createViewerStateTemplate do the following:
this will override the delete key ("Del") when in your viewer state. "delete_point" is the key code and corresponds to the key code in "menu.addActionItem". when the user hits the delete key, the user will call what would normally be called when selecting the item from the right mouse button menu. "delete selected points" is the description, and and can be anything you would like. the important part is to use the correct key string, "Del" for delete, "UpArrow" for up arrow, "ENTER" for enter, etc...
su.hotkey is part of a library that is already imported in your viewer sate. it handles a lot of what you could be doing manually as shown in the docs: https://www.sidefx.com/docs/houdini/hom/state_menus.html#hotkeys [www.sidefx.com]
hope that helps
state_typename = kwargs["type"].definition().sections()["DefaultState"].contents() menu = hou.ViewerStateMenu(state_typename + "_menu", state_label) del_key = su.hotkey(state_typename, "delete_point", "Del", "delete selected points") menu.addActionItem("delete_point", "delete selected points", hotkey=del_key) template.bindMenu(menu)
this will override the delete key ("Del") when in your viewer state. "delete_point" is the key code and corresponds to the key code in "menu.addActionItem". when the user hits the delete key, the user will call what would normally be called when selecting the item from the right mouse button menu. "delete selected points" is the description, and and can be anything you would like. the important part is to use the correct key string, "Del" for delete, "UpArrow" for up arrow, "ENTER" for enter, etc...
su.hotkey is part of a library that is already imported in your viewer sate. it handles a lot of what you could be doing manually as shown in the docs: https://www.sidefx.com/docs/houdini/hom/state_menus.html#hotkeys [www.sidefx.com]
hope that helps
- Control_Vertex
- Member
- 161 posts
- Joined: 5月 2015
- Offline
- yonatanbary
- Member
- 4 posts
- Joined: 8月 2022
- Offline
cval
Thank you so much for your answer @playBalster!
I will test this as soon as I can
Hey @cval, were you able to make it work?
From my testing I can’t override these specific shortcuts.
My solution is to remove these shortcuts using the hotkeys python module and then onExit to assign them back, but it’s not good practice I suppose.
- kodra
- Member
- 373 posts
- Joined: 6月 2023
- Offline
- yonatanbary
- Member
- 4 posts
- Joined: 8月 2022
- Offline
kodraI did a little run through all the characters and the ones who seem to be "locked" are:
Is there an easy way to know which hotkeys are "free to use" by a Python state?
d (Display options) e (Scale tool) j (Modify Channels) r (Rotate Tool) s (Volatile Select Mode) t (Move Tool) w (Wireframe) And also these special characters ` \ ?
I wish we could override these in python states!
- tamte
- Member
- 8769 posts
- Joined: 7月 2007
- Offline
yonatanbaryAre you talking about H20?kodraI did a little run through all the characters and the ones who seem to be "locked" are:
Is there an easy way to know which hotkeys are "free to use" by a Python state?d (Display options) e (Scale tool) j (Modify Channels) r (Rotate Tool) s (Volatile Select Mode) t (Move Tool) w (Wireframe) And also these special characters ` \ ?
I wish we could override these in python states!
while I don't have much experience with Pyhon States limitations I'd find it odd if these were still an issue especially since Car Rig Python State in H20 uses hotkeys like WASD for movement and they seem to work
Edited by tamte - 2023年12月17日 16:38:25
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- kodra
- Member
- 373 posts
- Joined: 6月 2023
- Offline
I tried to set move tool's hotkey to G (like in Blender). That breaks almost all the built-in Python states, since they all use G.
Ideally it shouldn't break Python states, unless the specific state has transform handle (so move tool makes sense).
I still don't know when Python state's hotkeys take precedence over Houdini's tho.
Ideally it shouldn't break Python states, unless the specific state has transform handle (so move tool makes sense).
I still don't know when Python state's hotkeys take precedence over Houdini's tho.
Edited by kodra - 2023年12月17日 22:21:02
-
- Quick Links