EnlightenPopover
open class EnlightenPopover : NSPopover, NSPopoverDelegate
A sizeable, detachable, and fitting, popover that renders a Markdown string.
-
The view relative to which the popover should be positioned.
Declaration
Swift
public weak var positioningView: NSView? -
The edge of
positioningViewthe popover should prefer to be anchored to.Declaration
Swift
public var preferredEdge: NSRectEdge? -
Whether the popover is fitted within
positioningView‘s window.Declaration
Swift
public var fitInWindow: Bool -
The padding between the popover and window frame when
fitInWindowis true.Declaration
Swift
public var windowInnerPadding: CGFloat -
Whether the popover is detachable.
Declaration
Swift
public var canDetach: Bool -
The maximum width of the popover.
Declaration
Swift
public var maxWidth: CGFloat { get set }
-
The popover’s content view controller.
Declaration
Swift
public var popoverContentViewController: EnlightenPopoverContentViewController { get } -
The popover’s
EnlightenPopoverDelegatedelegate.Declaration
Swift
public var enlightenPopoverDelegate: EnlightenPopoverDelegate? { get set } -
The maximum height of the popover.
Scrolling is enabled if the
EnlightenDownViewexceeds the maximum height.Declaration
Swift
public var maxHeight: CGFloat { get set } -
Whether the Markdown content should be center aligned.
Declaration
Swift
public var doesCenterAlignContent: Bool { get set }
-
Initializes a newly allocated Enlighten popover.
Throws
Throws aDownErrorsif loading the Markdown string fails.Declaration
Swift
public init(markdownString: String, maxWidth: CGFloat, maxHeight: CGFloat = 500) throwsParameters
markdownStringThe Markdown string rendered in the popover.
maxWidthThe maximum width of the popover.
maxHeightThe maximum height of the popover.
-
Undocumented
Declaration
Swift
public convenience init(maxWidth: CGFloat, maxHeight: CGFloat = 500) -
Undocumented
Declaration
Swift
public required init?(coder: NSCoder)
-
Resets the width of the popover’s
EnlightenDownView.Used during a Markdown string update.
Declaration
Swift
open func resetDownViewWidth() -
Resets the width of the popover’s content and
EnlightenDownViewto the original maximum width.Used during a Markdown string update.
Declaration
Swift
open func resetWidth() -
Resizes the popover’s content size so that it is the minimum size needed to contain its
EnlightenDownView.If the
fitInWindowproperty is true, this method will attempt to fit theEnlightenDownViewwithin the window frame.Declaration
Swift
open func sizeToFit() -
Updates the positioning rectangle of a shown popover.
Note: The popover’s position only needs to be updated programmatically if
show(relativeTo:in:preferredEdge:)was used to present the popover.Declaration
Swift
open func updatePositionIfShown(to positioningRect: NSRect)Parameters
positioningRectThe new positioning rectangle for the popover.
-
Presents the popover if needed.
This is determined by the
needsToShowPopoverproperty and ensures the Markdown has finished loading.Declaration
Swift
open func showPopoverIfNeeded() -
Shows the popover anchored to the specified view. Uses a heuristic method to determine the best anchoring edge.
Declaration
Swift
open func show(relativeTo positioningView: NSView)Parameters
positioningViewThe anchoring view.
-
Shows the popover anchored to a positioning frame in a content view.
If the popover’s Markdown content is not loaded, will wait for it to finish before showing the popover.
Declaration
Swift
open func show(relativeTo positioningRectInWindow: NSRect, in contentView: NSView, preferredEdge: NSRectEdge)Parameters
positioningRectInWindowThe rectangle within
contentViewrelative to which the popover should be positioned.contentViewThe window content view relative to which the popover should be positioned.
preferredEdgeThe edge of
positioningRectInWindowthe popover should prefer to be anchored to. -
Shows the popover anchored to the specified view.
Unlike the other presentation methods, this one shows the popover regardless of the popover’s content loading state .
Declaration
Swift
open func showLoaded(relativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge)Parameters
positioningRectThe rectangle within positioningView relative to which the popover should be positioned.
positioningViewThe view relative to which the popover should be positioned.
preferredEdgeThe edge of positioningView the popover should prefer to be anchored to.
-
Renders the given CommonMark Markdown string into HTML, updates the
EnlightenDownViewwhile keeping the style intact, and resizes the popover’s content size.Important
Errors thrown during the loading of the Markdown string are passed to the delegate’s
EnlightenPopoverDelegate.enlightenPopoverFailedToLoad(downError:)method.Declaration
Swift
open func update(markdownString: String, shouldCenterAlign: Bool = false, newMaxWidth: CGFloat? = nil, waitForPopoverClosure: Bool = false)Parameters
markdownStringA string containing CommonMark Markdown.
shouldCenterAlignWhether the Markdown content should be center aligned.
newMaxWidthThe new max width of the popover.
waitForPopoverClosureWhether to wait for the popover to close before updating. The default value is
false.
-
A heuristic method for determining the best anchor edge for a view.
The window quadrant the view is located in is used to determine the best edge.
Declaration
Swift
open func bestEdge(for view: NSView) -> NSRectEdgeParameters
viewThe anchoring view.
Return Value
The best anchoring edge for the view.
-
Undocumented
Declaration
Swift
open func popoverShouldDetach(_ popover: NSPopover) -> Bool -
Undocumented
Declaration
Swift
open func popoverWillShow(_ notification: Notification) -
Undocumented
Declaration
Swift
open func popoverDidClose(_ notification: Notification)
-
Shows the popover anchored to the specified view.
If the popover’s Markdown content is not loaded, will wait for it to finish before showing the popover.
Declaration
Swift
override open func show(relativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge)Parameters
positioningRectThe rectangle within positioningView relative to which the popover should be positioned.
positioningViewThe view relative to which the popover should be positioned.
preferredEdgeThe edge of positioningView the popover should prefer to be anchored to.
-
Undocumented
Declaration
Swift
override open func close()
EnlightenPopover Class Reference