Disable hotkeys in viewer H17

   2146   9   3
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Hi. Can I temporarily disable all viewer hotkeys in H17 without using custom python state?
Edited by Alexey Vanzhula - Oct. 21, 2018 11:26:03
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
396 posts
Joined: Feb. 2018
Offline
Hello,

you can disable the example viewer state hotkeys from the Hotkey Manager:

“Houdini|Panes|Geometry Viewers|Operations|Modeling (SOP) Operations|sidefx_bend Operation”
“Houdini|Panes|Geometry Viewers|Operations|Modeling (SOP) Operations|sidefx_stroke Operation”

or simply remove the $HFS/viewer_states folder.

-mab
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
_mab_
Hello,

you can disable the example viewer state hotkeys from the Hotkey Manager:

“Houdini|Panes|Geometry Viewers|Operations|Modeling (SOP) Operations|sidefx_bend Operation”
“Houdini|Panes|Geometry Viewers|Operations|Modeling (SOP) Operations|sidefx_stroke Operation”

or simply remove the $HFS/viewer_states folder.

-mab

Hi. I need to temporarily disable hotkeys in my tools. Currently I disabled it with Qt. But maybe H17 has some improvements in this area
Edited by Alexey Vanzhula - Oct. 22, 2018 15:03:20
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
98 posts
Joined: Aug. 2015
Offline
Hi, there aren't any hotkey changes in H17 that will facilitate temporarily disabling viewer hotkeys.

However, you could write a tool in python that manipulates the hotkey manager to remove all of the viewer hotkeys. The hotkey manager (hou.hotkeys) is now exposed in python.
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
hotkeys HOM module was available from H16.5, but I can't find function to remove all hotkeys
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
98 posts
Joined: Aug. 2015
Offline
vux
hotkeys HOM module was available from H16.5, but I can't find function to remove all hotkeys

The interface was re-organized a bit and documented in H17. There isn't a wholesale clear everything function so what you'd have to do is traverse the tree and clear the hotkeys you want cleared, even if you want to clear them all.

You can look at $HFS/houdini/python2.7libs/hotkeys/mainwidget.py in the modelGetAllCommands() function for an example of traversing the hotkey tree.
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
rafeek
vux
hotkeys HOM module was available from H16.5, but I can't find function to remove all hotkeys

The interface was re-organized a bit and documented in H17. There isn't a wholesale clear everything function so what you'd have to do is traverse the tree and clear the hotkeys you want cleared, even if you want to clear them all.

You can look at $HFS/houdini/python2.7libs/hotkeys/mainwidget.py in the modelGetAllCommands() function for an example of traversing the hotkey tree.

Thank you. I'll inspect it
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
import hou

def clear_hotkeys(ctx=''):
    exclude_cmds = 'Cut', 'Copy', 'Paste'
    for key in hou.hotkeys.contextsInContext(ctx):
        if key['symbol'] == 'inputfield':
            continue
        for key_ in hou.hotkeys.commandsInContext(key['symbol']):
            if key_['label'] in exclude_cmds:
                continue
            hou.hotkeys.clearAssignments(key_['symbol'])
        clear_hotkeys(key['symbol'])

clear_hotkeys()
Edited by Alexey Vanzhula - Oct. 23, 2018 15:13:29
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
98 posts
Joined: Aug. 2015
Offline
vux
import hou

def clear_hotkeys(ctx=''):
    exclude_cmds = 'Cut', 'Copy', 'Paste'
    for key in hou.hotkeys.contextsInContext(ctx):
        if key['symbol'] == 'inputfield':
            continue
        for key_ in hou.hotkeys.commandsInContext(key['symbol']):
            if key_['label'] in exclude_cmds:
                continue
            hou.hotkeys.clearAssignments(key_['symbol'])
        clear_hotkeys(key['symbol'])

clear_hotkeys()

Ok looks good now! I first saw the non-recursive version and was about to comment.

I would suggest saving the assignments into a dict to make it easy to restore. Also note that the ‘label’ field isn't unique.
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
rafeek
clear_hotkeys()

It can be restored very easy:

map = hou.hotkeys.currentKeymap()

clear_hotkeys()

your commands

hou.hotkeys.loadKeymap(map)
Edited by Alexey Vanzhula - Oct. 23, 2018 15:29:20
https://gumroad.com/alexeyvanzhula [gumroad.com]
  • Quick Links