pub enum MenuItem {
Show 19 variants Custom(Id<Object>), About(String), Hide, Services, HideOthers, ShowAll, CloseWindow, Quit, Copy, Cut, Undo, Redo, SelectAll, Paste, EnterFullScreen, Minimize, Zoom, ToggleSidebar, Separator,
}
Available on crate feature appkit only.
Expand description

Represents varying NSMenuItem types - e.g, a separator vs an action. If you need something outside of the stock item types, you can create a Custom variant that supports dispatching a callback on the Rust side of things.

Variants

Custom(Id<Object>)

A custom MenuItem. This type functions as a builder, so you can customize it easier. You can (and should) create this variant via the new(title) method, but if you need to do something crazier, then wrap it in this and you can hook into the Cacao menu system accordingly.

About(String)

Shows a standard “About” item, which will bring up the necessary window when clicked (include a credits.html in your App to make use of here). The argument baked in here should be your app name.

Hide

A standard “hide the app” menu item.

Services

A standard “Services” menu item.

HideOthers

A “hide all other windows” menu item.

ShowAll

A menu item to show all the windows for this app.

CloseWindow

Close the current window.

Quit

A “quit this app” menu icon.

Copy

A menu item for enabling copying (often text) from responders.

Cut

A menu item for enabling cutting (often text) from responders.

Undo

An “undo” menu item; particularly useful for supporting the cut/copy/paste/undo lifecycle of events.

Redo

An “redo” menu item; particularly useful for supporting the cut/copy/paste/undo lifecycle of events.

SelectAll

A menu item for selecting all (often text) from responders.

Paste

A menu item for pasting (often text) into responders.

EnterFullScreen

A standard “enter full screen” item.

Minimize

An item for minimizing the window with the standard system controls.

Zoom

An item for instructing the app to zoom. Your app must react to this with necessary window lifecycle events.

ToggleSidebar

An item for automatically telling a SplitViewController to hide or show the sidebar. This only works on macOS 11.0+.

Separator

Represents a Separator. It’s useful nonetheless for separating out pieces of the NSMenu structure.

Implementations

Returns a Custom menu item, with the given title. You can configure this further with the builder methods on this object.

Configures the a custom item to have specified key equivalent. This does nothing if called on a MenuItem type that is not Custom,

Sets the modifier key flags for this menu item. This does nothing if called on a MenuItem that is not Custom.

Attaches a target/action handler to dispatch events. This does nothing if called on a MenuItem that is not Custom.

Note that we use an extra bit of unsafety here to pass over a heap’d block. We need to do this as some menu items live in odd places (the system menu bar), and we need the handlers to persist. We inject a custom dealloc method to pull the pointer back and drop the handler whenever the menu item goes kaput.

Trait Implementations

Formats the value using the given formatter. Read more

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.

Calls U::from(self).

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

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.