Houdini 20.5 Python scripting hou hou.qt

hou.qt.resolveKeyEvent HOM function

Resolves a Qt key event to a hotkey symbol representing a command/action.

resolveKeyEvent(qtkeyevent, override_contexts) str

Resolves a Qt key event against either an automatically constructed resolve info or a specified list of contexts. Returns a hotkey symbol or an empty string. It is meant to be called from a widget’s key event handlers.

Note

Unless specifying override_contexts, this method should only be called from a widget event handler method.

The following example shows how this method can be used in a widget’s key handler:

class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        hou.qt.registerKeyResolveInfoCallback(self, self.key_resolve_info_callback)
    def __del__(self):
        hou.qt.unregisterKeyResolveInfoCallback(self)
        super().__del__()
    def key_resolve_info_callback(self, **kwargs):
        return {'contexts':['h.my.widget.context']}
    def keyPressEvent(self, event):
        symbol = hou.qt.resolveKeyEvent(event)
        if symbol == "h.my.widget.category.action":
            # Execute action
            # ...
            event.accept()

See also hou.qt.registerKeyResolveInfoCallback() and hou.qt.unregisterKeyResolveInfoCallback().

hou.qt