Instance Method

addToolTip(_:owner:userData:)

Creates a tooltip for a defined area the view and returns a tag that identifies the tooltip rectangle.

Declaration

func addToolTip(_ rect: NSRect, owner: Any, userData data: UnsafeMutableRawPointer?) -> NSView.ToolTipTag

Parameters

aRect

A rectangle defining the region of the view to associate the tooltip with.

anObject

An object from which to obtain the tooltip string. The object should either implement view(_:stringForToolTip:point:userData:), or return a suitable string from its description method. (It can therefore simply be an NSString object.)

userData

Any additional information you want to pass to view(_:stringForToolTip:point:userData:); it is not used if anObject does not implement this method.

Return Value

An integer tag identifying the tooltip; you can use this tag to remove the tooltip.

Discussion

The tooltip string is obtained dynamically from anObject by invoking either the NSToolTipOwner informal protocol method view(_:stringForToolTip:point:userData:), if implemented, or the NSObjectProtocol protocol method description.

See Also

Tooltips

func removeAllToolTips()

Removes all tooltips assigned to the view.

func removeToolTip(NSView.ToolTipTag)

Removes the tooltip identified by specified tag.

var toolTip: String?

The text for the view’s tooltip.