Struct druid::menu::MenuItem

source ·
pub struct MenuItem<T> { /* private fields */ }
Expand description

An item in a menu.

See the module level documentation for more on how to use menus.

Implementations§

Create a new menu item with a given name.

Provide a callback that will be invoked when this menu item is chosen.

Provide a Command that will be sent when this menu item is chosen.

This is equivalent to self.on_activate(move |ctx, _data, _env| ctx.submit_command(cmd)). If the command’s target is Target::Auto, it will be sent to the menu’s window if the menu is associated with a window, or to Target::Global if the menu is not associated with a window.

Provide a hotkey for activating this menu item.

This is equivalent to self.dynamic_hotkey(move |_, _| Some(HotKey::new(mods, key))

Provide a dynamic hotkey for activating this menu item.

The hotkey can change depending on the data.

Provide a callback for determining whether this menu item should be enabled.

Whenever the callback returns true, the item will be enabled.

Enable or disable this menu item.

Provide a callback for determining whether this menu item should be selected.

Whenever the callback returns true, the item will be selected.

Select or deselect this menu item.

Wraps this menu item in a lens, so that it can be added to a Menu<S>.

Trait Implementations§

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Performs the conversion.
Performs the conversion.
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more