GlobalShortcut

Register global keyboard shortcuts.

Modulerequire("yue.gui")
Typetable

This class can not be created by user, you can only receive its global instance from the globalshortcut property of the module:

gui.globalshortcut:unregisterall()

Methods

register(accelerator, callback)

Register a global keyboard shortcut that, callback will called when the accelerator is pressed.

An unsigned ID will returned on success, which can be used to undo the registration. -1 will be returned on error.

This API will fail silently when the accelerator is already taken by other apps, there is no way to know if an accelerator has already been registered by other apps.

Parameters

Return

integer

unregister(id)

Unregister the shortcut with the id returned by register.

Parameters

unregisterall()

Unregister all shortcuts registered in this app.