Jump to content

hou.hotkeys.addCommand not working


natalia

Recommended Posts

Hey Everyone has anyone used hou.hotkeys ?

I've made a tool and would like to have a shortcut assigned to it when its loaded. I can create a shelf and add tools to it through python with the hou.shelves library. But assigning a shortcut to the tool is :blink:.

I tried to understand how the shortcut was assigned to the tool by doing it manually. 

For example Ctrl + Alt + Shift + T to the tool called My Custom Tool

Then I was curious to find what the hotkey symbol the tool was using hou.hotkeys.hotkeySymbol. The examples of the documentation show a strict dot notation but running this command will return something along these lines with a colon ?

>>> hou.hotkeys.hotkeySymbol("Houdini/My Custom Tool")
h.tools:my_custom_tool

 

Regardless, with that info, trying to assign this through python seemed to work. The edit tool window will register and show the assignment, as well as the HotKey Manager. However pressing the shortcut doesn't work and doesn't trigger the tool code

hou.hotkeys.addCommand("h.tool:my_custom_tool","My Custom Tool", "This is a custom tool")
hou.hotkeys.addAssignment("h.tool:my_custom_tool","Alt+Ctrl+Shift+T")

Weird behaviour is deleting the shortcut in the Hotkey manager and reassigning it doesn't work either.

I need to manually run hou.hotkeys.removeHotkeySymbol("h.tool:my_custom_tool") for it to work again when setting it through the Hotkey Editor manually.

It seems the hou.hotkeys.addCommand is missing something ? its not linking to the command to the tool correctly to the shortcut even though visually in the Hotkey editor and the edit tool window hotkeys tab shows properly.

Did anyone face this issue ? Is this how we assign hotkeys to a tool through python ?

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...