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
imageAn image for the status item button.
lengthThe length of the status item.
-
Constructs an
NSMenuto display for the status item.Warning
You must override this method.Declaration
Swift
open func buildMenu() -> NSMenuReturn Value
A menu object.
-
The action to be executed on the
.leftMouseDownevent.Warning
You must override this method.Declaration
Swift
open func leftClickAction() -
The action to be executed on
.rightMouseUpevent.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
NSMenuItemthat calls this method.Declaration
Swift
@objc public func quit()
View on GitHub
StatusItemController Class Reference