MenuItem

public struct MenuItem

A menu item has a title, an associated help text, and an action to execute on activation.

  • Gets or sets the title for the menu item

    Declaration

    Swift

    public var title: String
  • Gets or sets the help text for the menu item, this is show next to the title

    Declaration

    Swift

    public var help: String
  • Gets or sets the action to be invoked when the menu is triggered, can be nil

    Declaration

    Swift

    public var action: (() -> Void)?
  • This is the global setting that can be used as a global shortcut to invoke the action on the menu.

    Declaration

    Swift

    public var shortcut: Key?
  • The style to use for rendering this menu

    Declaration

    Swift

    public var style: MenuItemStyle
  • The hotkey is used when the menu is active, the shortcut can be triggered when the menu is not active.

    For example HotKey would be “N” when the File Menu is open (assuming there is a “_New” entry if the ShortCut is set to “Control-N”, this would be a global hotkey that would trigger as well

    Declaration

    Swift

    public var hotkey: Character?
  • Declaration

    Swift

    public init(title: String, help: String = "", action: (() -> Void)? = nil, shortcut: Key? = nil, hotkey: Character? = nil, style: MenuItemStyle = .plain)