pub struct ShortcutBuilder {
pub options: Options,
pub active_callback: Option<Callback<CallbackClosure<JsValue>>>,
pub failed_callback: Option<Callback<CallbackClosure<JsValue>>>,
}
Expand description
Provides a builder pattern for building application keyboard shortcuts.
For usage example please refer to Examples
Fields§
§options: Options
§active_callback: Option<Callback<CallbackClosure<JsValue>>>
§failed_callback: Option<Callback<CallbackClosure<JsValue>>>
Implementations§
Source§impl ShortcutBuilder
impl ShortcutBuilder
pub fn new() -> Self
Sourcepub fn key(self, key: &str) -> Self
pub fn key(self, key: &str) -> Self
Set the key
of a Shortcut
.
It is a string to specify the shortcut key, like “Ctrl+Alt+A”.
The key is consisted of zero or more modifiers and a key on your keyboard.
Only one key code is supported. Key code is case insensitive.
§List of supported modifiers:
- Ctrl
- Alt
- Shift
- Command: Command modifier maps to Apple key (⌘) on Mac, and maps to the Windows key on Windows and Linux.
§List of supported keys:
- Alphabet:
A
-Z
- Digits:
0
-9
- Function Keys:
F1
-F24
- Home / End / PageUp / PageDown / Insert / Delete
- Up / Down / Left / Right
- MediaNextTrack / MediaPlayPause / MediaPrevTrack / MediaStop
- Comma or
,
- Period or
.
- Tab or
\t
- Backquote or
`
- Enter or
\n
- Minus or
-
- Equal or
=
- Backslash or
\
- Semicolon or
;
- Quote or
'
- BracketLeft or
[
- BracketRight or
]
- Escape
Sourcepub fn active<F>(self, callback: F) -> Self
pub fn active<F>(self, callback: F) -> Self
Set the active callback of a Shortcut. It will be called when user presses the shortcut.
Sourcepub fn failed<F>(self, callback: F) -> Self
pub fn failed<F>(self, callback: F) -> Self
Set the failed callback of a Shortcut. It will be called when application passes an invalid key, or failed to register the key.
Sourcepub fn build(self) -> Result<Shortcut>
pub fn build(self) -> Result<Shortcut>
create nw_sys::Shortcut and return it
Sourcepub fn finalize(self) -> Result<ShortcutInfo>
pub fn finalize(self) -> Result<ShortcutInfo>
create nw_sys::Shortcut and return it with active_callback, failed_callback handlers
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShortcutBuilder
impl RefUnwindSafe for ShortcutBuilder
impl !Send for ShortcutBuilder
impl !Sync for ShortcutBuilder
impl Unpin for ShortcutBuilder
impl UnwindSafe for ShortcutBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more