StatusItemController
@MainActor
open class StatusItemController : NSObject, NSMenuDelegate
Controller for an NSStatusItem
. Designed to be subclassed.
Warning
You must subclass this controller.-
The status item.
Declaration
Swift
public let statusItem: NSStatusItem
-
Creates a new
StatusItemController
.Declaration
Swift
public init(image: NSImage, length: CGFloat = NSStatusItem.squareLength)
Parameters
image
An image for the status item button.
length
The length of the status item.
-
Constructs an
NSMenu
to display for the status item.Warning
You must override this method.Declaration
Swift
open func buildMenu() -> NSMenu
Return Value
A menu object.
-
The action to be executed on the
.leftMouseDown
event.Warning
You must override this method.Declaration
Swift
open func leftClickAction()
-
The action to be executed on
.rightMouseUp
event.Warning
You must override this method.Declaration
Swift
open func rightClickAction()
-
Opens the status item menu. You may wish to call this from
leftClickAction()
orrightClickAction()
.Declaration
Swift
public func openMenu()
-
Hides the status item menu.
Declaration
Swift
public func hideMenu()
-
Quits the application. You may wish to create an
NSMenuItem
that calls this method.Declaration
Swift
@objc public func quit()