Class

NSMenuItemCell

NSMenuItemCell is a class that handles the measurement and display of a single menu item in its encompassing frame. Instances of NSMenuItemCell work in conjunction with an NSMenuView object to control the overall appearance of the menu.

Overview

Symbols

Configuring Menu-Item Attributes

var menuItem: NSMenuItem?

The menu item object associated with the cell.

Calculating the Size of a Menu Item

func calcSize()

Calculates the minimum required width and height of the receiver’s menu item.

var needsSizing: Bool

A Boolean value indicating whether the size of the menu needs to be calculated.

var imageWidth: CGFloat

The width of the image associated with the menu item.

var titleWidth: CGFloat

The width of the menu item’s text, measured in points.

var keyEquivalentWidth: CGFloat

The width of the menu item’s key equivalent string.

var stateImageWidth: CGFloat

The width of the image used to indicate the state of the menu item.

Getting the Menu Item’s Drawing Rectangle

func keyEquivalentRect(forBounds: NSRect)

Returns the rectangle into which the menu item’s key equivalent should be drawn.

func stateImageRect(forBounds: NSRect)

Returns the rectangle into which the menu item’s state image should be drawn.

func titleRect(forBounds: NSRect)

Returns the rectangle into which the menu item’s title should be drawn.

Drawing the Menu Item

func drawBorderAndBackground(withFrame: NSRect, in: NSView)

Draws the borders and background associated with the receiver’s menu item (if any).

func drawImage(withFrame: NSRect, in: NSView)

Draws the image associated with the menu item.

func drawKeyEquivalent(withFrame: NSRect, in: NSView)

Draws the key equivalent associated with the menu item.

func drawStateImage(withFrame: NSRect, in: NSView)

Draws the state image associated with the menu item.

func drawTitle(withFrame: NSRect, in: NSView)

Draws the title associated with the menu item.

var needsDisplay: Bool

A Boolean value indicating whether the menu item needs to be displayed.

Assigning a Tag

var tag: Int

The integer tag of the selected menu item.

Relationships

Inherits From