You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is an example of how to handle global keyboard events in an Edifice app.
KeyHandler=Callable[[QKeyEvent], None]
_global_key_handlers: set[KeyHandler] =set()
defhandle_key_up_global(event: QKeyEvent) ->None:
""" Use this as the on_key_up event handler for the root Window component. Then children can use the use_key_up_global Hook to register their own global key handlers. """forhandlerin_global_key_handlers:
handler(event)
defuse_key_up_global(key: Qt.Key, key_up_handler: KeyHandler) ->None:
""" Hook to register a global key handler for key up events. Example:: use_key_up_global(Qt.Key.Key_Escape, lambda _: go_back()) """defhandler(event: QKeyEvent) ->None:
# https://doc.qt.io/qtforpython-6/PySide6/QtCore/Qt.html#PySide6.QtCore.PySide6.QtCore.Qt.Keyifevent.key() ==key:
event.accept()
key_up_handler(event)
defsetup():
_global_key_handlers.add(handler)
defcleanup():
_global_key_handlers.remove(handler)
returncleanupuse_effect(setup, (key, key_up_handler))
Here is an example of how to handle global keyboard events in an Edifice app.
The text was updated successfully, but these errors were encountered: