Protocol

NSTextInputClient

A set of methods that text views must implement to interact properly with the text input management system.

Declaration

@protocol NSTextInputClient

Overview

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

Topics

Handling Marked Text

- hasMarkedText

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

Required.

- markedRange

Returns the range of the marked text.

Required.

- selectedRange

Returns the range of selected text.

Required.

- setMarkedText:selectedRange:replacementRange:

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

Required.

- unmarkText

Unmarks the marked text.

Required.

- validAttributesForMarkedText

Returns an array of attribute names recognized by the receiver.

Required.

Storing Text

- attributedSubstringForProposedRange:actualRange:

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

Required.

- insertText:replacementRange:

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

Required.

Getting Character Coordinates

- characterIndexForPoint:

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

Required.

- firstRectForCharacterRange:actualRange:

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

Required.

Binding Keystrokes

- doCommandBySelector:

Invokes the action specified by the given selector.

Required.

Optional Methods

- attributedString

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

- fractionOfDistanceThroughGlyphForPoint:

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

- baselineDeltaForCharacterAtIndex:

Returns the baseline position of a given character relative to the origin of rectangle returned by firstRectForCharacterRange:actualRange:.

- windowLevel

Returns the window level of the receiver.

- drawsVerticallyForCharacterAtIndex:

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

Relationships

Conforming Types

See Also

Input Management

NSTextInput

A set of methods that text views must implement to interact properly with the text input management system.

NSTextInputContext

An object that represents the Cocoa text input system.

NSTextAlternatives

A list of alternative strings for a piece of text.