Struct ShortcutBuilder

Source
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

Source

pub fn new() -> Self

Source

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

NWJS Documentation

Source

pub fn active<F>(self, callback: F) -> Self
where F: FnMut(JsValue) -> Result<(), JsValue> + 'static,

Set the active callback of a Shortcut. It will be called when user presses the shortcut.

NWJS Documentation

Source

pub fn failed<F>(self, callback: F) -> Self
where F: FnMut(JsValue) -> Result<(), JsValue> + 'static,

Set the failed callback of a Shortcut. It will be called when application passes an invalid key, or failed to register the key.

NWJS Documentation

Source

pub fn build(self) -> Result<Shortcut>

create nw_sys::Shortcut and return it

Source

pub fn finalize(self) -> Result<ShortcutInfo>

create nw_sys::Shortcut and return it with active_callback, failed_callback handlers

Trait Implementations§

Source§

impl Default for ShortcutBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V