LavaUI docs GitHub

class MenuController

Swift

Constructors

init()

Creates a controller with an empty menubar.

Sources/LavaMenu/Menu.swift:678

init(_ bar: MenuBar)

Creates a controller holding bar, resolved.

Sources/LavaMenu/Menu.swift:684

init(@MenuBarBuilder _ content: () -> [Menu])

Creates a controller from a @MenuBarBuilder block.

Sources/LavaMenu/Menu.swift:691

Properties

var actionIDs: Set<MenuID> { get }

The ids that have actions, for tests and diagnostics.

Sources/LavaMenu/Menu.swift:740

var model: MenuModel { get }

The menubar as last resolved.

Sources/LavaMenu/Menu.swift:674

Methods

@discardableResult func activate(_ id: MenuID) -> Bool

Invoke the action for id if present (even if the item is disabled in the model — callers should check model.item(id:) when enforcing UI).

Sources/LavaMenu/Menu.swift:716

@discardableResult func activate(_ id: String) -> Bool

Runs the action registered under the string id id. Returns whether one ran.

Sources/LavaMenu/Menu.swift:722

@discardableResult func activate(matchingKey key: Int32, mods: Int32, primary: Int32 = KeyShortcut.platformPrimaryMod) -> Bool

Activate the first enabled item matching the key event.

Sources/LavaMenu/Menu.swift:728

@discardableResult func update(_ bar: MenuBar) -> Bool

Rebuild from a menubar. Returns whether the platform-facing model changed.

Sources/LavaMenu/Menu.swift:699

@discardableResult func update(@MenuBarBuilder _ content: () -> [Menu]) -> Bool

Rebuilds from a @MenuBarBuilder block. Returns whether the model changed.

Sources/LavaMenu/Menu.swift:709