Houdini 20.5 Python scripting hou hou.qt

hou.qt.registerKeyResolveInfoCallback HOM function

Registers a Python callback that Houdini will call for the given widget when building the key resolve info against which key events are resolved.

registerKeyResolveInfoCallback(widget, callback)

widget

The widget for which to register the callback. Each widget can only have one such callback registered.

callback

A callable Python object, such as a function or bound method. Houdini will call this function when it needs to build the key resolve info for a hierarchy that includes this widget.

The callback should return a dictionary containing a list of contexts under the symbol contexts.

You can add **kwargs to the argument list to accept all keyword arguments to be safe from future changes:

def key_resolve_info_callback(**kwargs):
    return {'contexts':['foo','bar']}

Raises hou.OperationFailed if the widget already has a callback registered.

The following example shows to set up the callback for a widget subclass:

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':['foo', 'bar']}

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

hou.qt