Struct workflow_nw::ipc::imports::MenuItem
source · pub struct MenuItem { /* private fields */ }Expand description
Interface for controlling menu items. For usage example please refer to nw_sys::menu
Implementations§
source§impl MenuItem
impl MenuItem
source§impl MenuItem
impl MenuItem
sourcepub fn icon_is_template(&self) -> bool
pub fn icon_is_template(&self) -> bool
(Mac) Get whether icon image is treated as “template”.
source§impl MenuItem
impl MenuItem
sourcepub fn set_icon_is_template(&self, value: bool)
pub fn set_icon_is_template(&self, value: bool)
(Mac) Set whether icon image is treated as “template” (true by default). When the property is set to true the image is treated as “template” and the system automatically ensures proper styling according to the various states of the status item (e.g. dark menu, light menu, etc.). Template images should consist only of black and clear colours and can use the alpha channel in the image to adjust the opacity of black content. It has no effects on Linux and Windows.
source§impl MenuItem
impl MenuItem
sourcepub fn set_tooltip(&self, tooltip: &str)
pub fn set_tooltip(&self, tooltip: &str)
(Mac) Set the tooltip of a MenuItem, it can only be plain text. A tooltip is short string that describes the menu item, it will show when you hover your mouse on the item.
source§impl MenuItem
impl MenuItem
sourcepub fn set_checked(&self, checked: bool)
pub fn set_checked(&self, checked: bool)
Set whether the MenuItem is checked. Usually if a MenuItem is checked. There will be a mark on the left side of it. It’s used mostly to indicate whether an option is on.
source§impl MenuItem
impl MenuItem
sourcepub fn set_enabled(&self, enabled: bool)
pub fn set_enabled(&self, enabled: bool)
Set whether the MenuItem is enabled. An disabled MenuItem will be greyed out and you will not be able to click on it.
source§impl MenuItem
impl MenuItem
Set the submenu of a MenuItem, the submenu must be a Menu object. You should set submenu in the option when creating the MenuItem. Changing it at runtime is slow on some platforms.
source§impl MenuItem
impl MenuItem
source§impl MenuItem
impl MenuItem
source§impl MenuItem
impl MenuItem
sourcepub fn set_key(&self, key: &str)
pub fn set_key(&self, key: &str)
Set shortcut key
Valid Keys for All Platforms Alphabet: a-z Digits: 0-9 Other keys on main area: [ , ] , ’ , , , . , / , ` , - , = , \ , ’ , ; , Tab Esc Down , Up , Left , Right W3C DOM Level 3 KeyboardEvent Key Values: KeyA (same as A), Escape (same as Esc), F1, ArrowDown (same as Down) etc. Special Keys for Mac Only
On Mac, you can also use special keys as shortcut key with String.fromCharCode(specialKey).
Here are some useful keys:
28: Left (←) 29: Right (→) 30: Up (↑) 31: Down (↓) 27: Escape (⎋) 11: PageUp (⇞) 12: PageDown (⇟) For full list of special keys supported on Mac, see NSMenuItem.keyEquivalent and NSEvent: Function-Key Unicodes.
source§impl MenuItem
impl MenuItem
sourcepub fn modifiers(&self) -> String
pub fn modifiers(&self) -> String
Get modifier keys A string to specify the modifier keys for the shortcut of the menu item. It should be the concatenation of the following strings: cmd / command / super, shift, ctrl, alt. e.g. “cmd+shift+alt”. cmd represents different keys on all platforms: Windows key (Windows) on Windows and Linux, Apple key (⌘) on Mac. super and command are aliases of cmd.
Methods from Deref<Target = JsValue>§
pub const NULL: JsValue = _
pub const UNDEFINED: JsValue = _
pub const TRUE: JsValue = _
pub const FALSE: JsValue = _
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the f64 value of this JS value if it’s an instance of a
number.
If this JS value is not an instance of a number then this returns
None.
sourcepub fn as_string(&self) -> Option<String>
pub fn as_string(&self) -> Option<String>
If this JS value is a string value, this function copies the JS string
value into wasm linear memory, encoded as UTF-8, and returns it as a
Rust String.
To avoid the copying and re-encoding, consider the
JsString::try_from() function from js-sys
instead.
If this JS value is not an instance of a string or if it’s not valid
utf-8 then this returns None.
§UTF-16 vs UTF-8
JavaScript strings in general are encoded as UTF-16, but Rust strings
are encoded as UTF-8. This can cause the Rust string to look a bit
different than the JS string sometimes. For more details see the
documentation about the str type which contains a few
caveats about the encodings.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool value of this JS value if it’s an instance of a
boolean.
If this JS value is not an instance of a boolean then this returns
None.
sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Tests whether this JS value is undefined
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Tests whether the type of this JS value is function.
sourcepub fn js_in(&self, obj: &JsValue) -> bool
pub fn js_in(&self, obj: &JsValue) -> bool
Applies the binary in JS operator on the two JsValues.
sourcepub fn loose_eq(&self, other: &JsValue) -> bool
pub fn loose_eq(&self, other: &JsValue) -> bool
Compare two JsValues for equality, using the == operator in JS.
sourcepub fn unsigned_shr(&self, rhs: &JsValue) -> u32
pub fn unsigned_shr(&self, rhs: &JsValue) -> u32
Applies the binary >>> JS operator on the two JsValues.
sourcepub fn checked_div(&self, rhs: &JsValue) -> JsValue
pub fn checked_div(&self, rhs: &JsValue) -> JsValue
Applies the binary / JS operator on two JsValues, catching and returning any RangeError thrown.
sourcepub fn pow(&self, rhs: &JsValue) -> JsValue
pub fn pow(&self, rhs: &JsValue) -> JsValue
Applies the binary ** JS operator on the two JsValues.
sourcepub fn lt(&self, other: &JsValue) -> bool
pub fn lt(&self, other: &JsValue) -> bool
Applies the binary < JS operator on the two JsValues.
sourcepub fn le(&self, other: &JsValue) -> bool
pub fn le(&self, other: &JsValue) -> bool
Applies the binary <= JS operator on the two JsValues.
sourcepub fn ge(&self, other: &JsValue) -> bool
pub fn ge(&self, other: &JsValue) -> bool
Applies the binary >= JS operator on the two JsValues.
sourcepub fn gt(&self, other: &JsValue) -> bool
pub fn gt(&self, other: &JsValue) -> bool
Applies the binary > JS operator on the two JsValues.
sourcepub fn unchecked_into_f64(&self) -> f64
pub fn unchecked_into_f64(&self) -> f64
Applies the unary + JS operator on a JsValue. Can throw.
Trait Implementations§
source§impl FromWasmAbi for MenuItem
impl FromWasmAbi for MenuItem
source§impl<'a> IntoWasmAbi for &'a MenuItem
impl<'a> IntoWasmAbi for &'a MenuItem
source§impl IntoWasmAbi for MenuItem
impl IntoWasmAbi for MenuItem
source§impl JsCast for MenuItem
impl JsCast for MenuItem
source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
instanceof check to see whether the JsValue
provided is an instance of this type. Read moresource§fn unchecked_from_js(val: JsValue) -> MenuItem
fn unchecked_from_js(val: JsValue) -> MenuItem
source§fn unchecked_from_js_ref(val: &JsValue) -> &MenuItem
fn unchecked_from_js_ref(val: &JsValue) -> &MenuItem
source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere
T: JsCast,
T. Read moresource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
T. Read moresource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
T. Read moresource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere
T: JsCast,
source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
source§impl LongRefFromWasmAbi for MenuItem
impl LongRefFromWasmAbi for MenuItem
§type Abi = <JsValue as LongRefFromWasmAbi>::Abi
type Abi = <JsValue as LongRefFromWasmAbi>::Abi
RefFromWasmAbi::Abisource§unsafe fn long_ref_from_abi(
js: <MenuItem as LongRefFromWasmAbi>::Abi,
) -> <MenuItem as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <MenuItem as LongRefFromWasmAbi>::Abi, ) -> <MenuItem as LongRefFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abisource§impl OptionFromWasmAbi for MenuItem
impl OptionFromWasmAbi for MenuItem
source§impl<'a> OptionIntoWasmAbi for &'a MenuItem
impl<'a> OptionIntoWasmAbi for &'a MenuItem
source§impl OptionIntoWasmAbi for MenuItem
impl OptionIntoWasmAbi for MenuItem
source§impl RefFromWasmAbi for MenuItem
impl RefFromWasmAbi for MenuItem
§type Abi = <JsValue as RefFromWasmAbi>::Abi
type Abi = <JsValue as RefFromWasmAbi>::Abi
Self are recovered from.§type Anchor = ManuallyDrop<MenuItem>
type Anchor = ManuallyDrop<MenuItem>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.source§unsafe fn ref_from_abi(
js: <MenuItem as RefFromWasmAbi>::Abi,
) -> <MenuItem as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <MenuItem as RefFromWasmAbi>::Abi, ) -> <MenuItem as RefFromWasmAbi>::Anchor
Auto Trait Implementations§
impl Freeze for MenuItem
impl RefUnwindSafe for MenuItem
impl !Send for MenuItem
impl !Sync for MenuItem
impl Unpin for MenuItem
impl UnwindSafe for MenuItem
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abisource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.