Protocol

NSTextInputClient

The NSTextInputClient protocol defines the methods that Cocoa text views must implement in order to interact properly with the text input management system. To create another text view class, you can either subclass NSTextView (and not NSText, for historical reasons), or subclass NSView and implement the NSTextInputClient protocol

Overview

Symbols

Handling Marked Text

func hasMarkedText()
Required.

Returns a Boolean value indicating whether the receiver has marked text.

func markedRange()
Required.

Returns the range of the marked text.

func selectedRange()
Required.

Returns the range of selected text.

func setMarkedText(Any, selectedRange: NSRange, replacementRange: NSRange)
Required.

Replaces a specified range in the receiver’s text storage with the given string and sets the selection.

func unmarkText()
Required.

Unmarks the marked text.

func validAttributesForMarkedText()
Required.

Returns an array of attribute names recognized by the receiver.

Storing Text

func attributedSubstring(forProposedRange: NSRange, actualRange: NSRangePointer?)
Required.

Returns an attributed string derived from the given range in the receiver's text storage.

func insertText(Any, replacementRange: NSRange)
Required.

Inserts the given string into the receiver, replacing the specified content.

Getting Character Coordinates

func characterIndex(for: NSPoint)
Required.

Returns the index of the character whose bounding rectangle includes the given point.

func firstRect(forCharacterRange: NSRange, actualRange: NSRangePointer?)
Required.

Returns the first logical boundary rectangle for characters in the given range.

Binding Keystrokes

func doCommand(by: Selector)
Required.

Invokes the action specified by the given selector.

Optional Methods

func attributedString()

Returns an attributed string representing the receiver's text storage.

func fractionOfDistanceThroughGlyph(for: NSPoint)

Returns the fraction of the distance from the left side of the character to the right side that a given point lies.

func baselineDeltaForCharacter(at: Int)

Returns the baseline position of a given character relative to the origin of rectangle returned by firstRect(forCharacterRange:actualRange:).

func windowLevel()

Returns the window level of the receiver.

func drawsVerticallyForCharacter(at: Int)

Informs the text input management system whether the protocol-conforming client renders the character at the given index vertically.

Relationships

Adopted By