setSelectedRange(_:affinity:stillSelecting:)
Sets the selection to a range of characters in response to user action.
Declaration
func setSelectedRange(_ charRange: NSRange, affinity: NSSelectionAffinity, stillSelecting stillSelectingFlag: Bool)Parameters
- charRange:
The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
- affinity:
The selection affinity for the selection. See Selectionaffinity for more information about how affinities work.
- stillSelectingFlag:
True to behave appropriately for a continuing selection where the user is still dragging the mouse, False otherwise. If True, the receiver doesn’t send notifications or remove the marking from its marked text. If False, the receiver posts an Didchangeselectionnotification to the default notification center and removes the marking from marked text if the new selection is greater than the marked region.
Discussion
This method resets the selection granularity to NSSelectByCharacter.
Special Considerations
In macOS 10.4 and later, if there are multiple selections, this method acts on the first selected subrange.