Struct MenuItemBuilder

Source
pub struct MenuItemBuilder {
    pub options: Options,
    pub callback: Option<Callback<CallbackClosure<JsValue>>>,
}
Expand description

MenuItem Builder

For usage example please refer to Examples

Fields§

§options: Options§callback: Option<Callback<CallbackClosure<JsValue>>>

Implementations§

Source§

impl MenuItemBuilder

Source

pub fn new() -> Self

Source

pub fn set_type(self, t: MenuItemType) -> Self

Type of MenuItem

NWJS Documentation

Source

pub fn label(self, label: &str) -> Self

Label for normal item or checkbox

NWJS Documentation

Source

pub fn icon(self, icon: &str) -> Self

Icon for normal item or checkbox

NWJS Documentation

Source

pub fn tooltip(self, tooltip: &str) -> Self

Tooltip for normal item or checkbox

NWJS Documentation

Source

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

The callback function when item is triggered by mouse click or keyboard shortcut

NWJS Documentation

Source

pub fn enabled(self, enabled: bool) -> Self

Whether the item is enabled or disabled. It’s set to true by default.

NWJS Documentation

Source

pub fn checked(self, checked: bool) -> Self

Whether the checkbox is checked or not. It’s set to false by default.

NWJS Documentation

Source

pub fn submenu(self, submenu: &Menu) -> Self

A submenu

NWJS Documentation

Source

pub fn submenus(self, items: Vec<MenuItem>) -> Self

Create submenu from menu items

NWJS Documentation

Source

pub fn key(self, key: &str) -> Self

The key of the shortcut

NWJS Documentation

Source

pub fn modifiers(self, modifiers: &str) -> Self

The modifiers of the shortcut

NWJS Documentation

Source

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

Source

pub fn finalize( self, ) -> Result<(MenuItem, Option<Callback<CallbackClosure<JsValue>>>)>

Trait Implementations§

Source§

impl Default for MenuItemBuilder

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