Class

NSPopover

The NSPopover class provides a means to display additional content related to existing content on the screen. The popover is positioned relative to the existing content.

Overview

An anchor is used to express the relation between these two units of content. A popover has an appearance that specifies its visual characteristics, as well as a behavior that determines which user interactions will cause the popover to close. A transient popover is closed in response to most user interactions, whereas a semi-transient popovers is closed when the user interacts with the window containing the popover's positioning view. Popovers with application-defined behavior are not usually closed on the developer's behalf.

The system automatically positions each popover relative to its positioning view and moves the popover whenever its positioning view moves. A positioning rectangle within the positioning view can be specified for additional granularity.

Popovers can be detached to become a separate window when they are dragged by implementing the appropriate delegate method.

Symbols

Popover’s Content View Control

var contentViewController: NSViewController?

The view controller that manages the content of the popover.

Popover Position and Size

var behavior: NSPopoverBehavior

Specifies the behavior of the popover.

func show(relativeTo: NSRect, of: NSView, preferredEdge: NSRectEdge)

Shows the popover anchored to the specified view.

var positioningRect: NSRect

The content size of the popover.

Popover Appearance

var appearance: NSAppearance?

The appearance of the popover.

var animates: Bool

Specifies if the popover is to be animated.

var contentSize: NSSize

The content size of the popover.

var isShown: Bool

The display state of the popover.

Closing a Popover

func performClose(Any?)

Attempts to close the popover.

func close()

Forces the popover to close without consulting its delegate.

Getting and Setting the Delegate

var delegate: NSPopoverDelegate?

The delegate of the popover.

Constants

NSPopoverAppearance

The set of predefined appearances for a popover.

Deprecated
NSPopoverBehavior

The appearance and disappearance behavior of a popover.

Notification User Info Keys

The following constants are used as keys in the userInfo dictionary for notifications pertaining to popovers.

Notifications

static let NSPopoverWillShow: NSNotification.Name

Sent before the popover is shown.

static let NSPopoverDidShow: NSNotification.Name

Sent after the popover has finished animating onscreen.

static let NSPopoverWillClose: NSNotification.Name

Sent before the popover is closed.

static let NSPopoverDidClose: NSNotification.Name

Sent after the popover has finished animating offscreen.