GlobalShortcut
Register global keyboard shortcuts.
| Header | #include "nativeui/global_shortcut.h" |
| Namespace | namespace nu |
| Type | class |
This class can not be created by user, you must create State first and
then receive an instance of GlobalShortcut via GlobalShortcut::GetCurrent.
nu::State state;
nu::GlobalShortcut* global_shortcut = nu::GlobalShortcut::GetCurrent();
Class methods
GlobalShortcut* GetCurrent()
Return current GlobalShortcut instance.
Return
GlobalShortcut*Methods
int Register(const Accelerator& accelerator, std::function<void()> 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
const Accelerator&acceleratorstd::function<void()>callback
Return
intvoid Unregister(int id)
Unregister the shortcut with the id returned by Register.
Parameters
intid
void UnregisterAll()
Unregister all shortcuts registered in this app.