Shows a window displaying the definition of the specified range of the attributed string.
SDK
- macOS 10.6+
Framework
- App
Kit
Declaration
func showDefinition(for attrString: NSAttributed String?, range targetRange: NSRange, options: [NSView.Definition Option Key : Any]? = nil, baselineOriginProvider originProvider: ((NSRange) -> NSPoint)? = nil)
Parameters
attrString
The attributed string for which to show the definition. If the view is an instance of NSTextView, the
attr
value can beString nil
, in which case the text view will automatically supply values suitable for displaying definitions for the specified range within its text content.range
The range of the attributed string to define. You can pass a zero-length range and the appropriate range will be auto-detected around the range's offset. That's the recommended approach when there is no selection.
options
An optional dictionary that specifies how the definition is displayed. See NSDefinition Presentation Constants for the key and it’s possible values.
originProvider
The originProvider block object should return the baseline origin for the first character at the adjusted range.
If the view is an instance of NSTextView, the originProvider can be
NULL
, in which case the text view will automatically supply values suitable for displaying definitions for the specified range within its text content.The block object takes a single argument:
- adjustedRange
The adjusted range.
The block object returns an
NSPoint
to be used as the baseline origin of the first character, in the view’s view coordinate system.
Discussion
This method does not cause scrolling, so clients should perform any necessary scrolling before calling this method.