Cross-platform native global hotkey helpers for MoonBit.
///|
test "global_hotkey can be probed safely" {
ignore(@global_hotkey.is_supported())
match @global_hotkey.create() {
Ok(manager) => manager.destroy()
Err(_) => ()
}
}fn GlobalHotkeyManager::register(self : GlobalHotkeyManager, accelerator : String) -> Result[Bool, String]test "register may be attempted on a live manager" {
match @global_hotkey.create() {
Ok(manager) => {
ignore(manager.register("Ctrl+Shift+F24"))
ignore(manager.unregister("Ctrl+Shift+F24"))
manager.destroy()
}
Err(_) => ()
}
}fn GlobalHotkeyManager::unregister(self : GlobalHotkeyManager, accelerator : String) -> Result[Bool, String]#external
pub type GlobalHotkeyStatetype RegistrationStoretest "manager creation can be attempted safely" {
match @global_hotkey.create() {
Ok(manager) => manager.destroy()
Err(_) => ()
}
}fn ensure_supported() -> Result[Unit, String]test "support can be checked without registering anything" {
ignore(@global_hotkey.ensure_supported())
}fn is_supported() -> Booltest "support detection can be queried" {
ignore(@global_hotkey.is_supported())
}Cross-platform native global hotkey helpers for MoonBit.