NSTextInputContext Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.6 and later.
Declared in
NSTextInputContext.h

Overview

An NSTextInputContext object represents the Cocoa text input system. The text input system communicates primarily with the client of the activated input context via the NSTextInputClient protocol.

Tasks

Creating an Input Context

Getting the Input Context and Client

Configuring the Input Context

Activating the Input Context

Handling Input Sources

Properties

acceptsGlyphInfo

A Boolean value that indicates whether the client handles NSGlyphInfoAttributeName or not.

@property BOOL acceptsGlyphInfo;
Discussion

The default value is determined by examining the return value from sending a validAttributesForMarkedText message to the client at initialization.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

allowedInputSourceLocales

The set of keyboard input source locales allowed when this input context is active.

@property(copy) NSArray *allowedInputSourceLocales;
Discussion

NSAllRomanInputSourcesLocaleIdentifier can be specified as a valid locale.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

client

The owner of this input context. (read-only)

@property(readonly) id <NSTextInputClient> client;
Discussion

The client (owner) of the input context, typically an NSView instance, retains its NSTextInputContext instance. The NSTextInputContext instance doesn't retain its client.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

keyboardInputSources

The array of keyboard text input source identifier strings available to the receiver. (read-only)

@property(readonly) NSArray *keyboardInputSources;
Discussion

The Text Input Source Services API identifies text input sources with text input source identifier strings (for example, com.apple.inputmethod.Kotoeri.Japanese) supplied by the underlying text input sources framework. The ID corresponds to the kTISPropertyInputSourceID attribute.

For more information on the Text Input Source Services API, see Text Input Source Services Reference.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

selectedKeyboardInputSource

The identifier string for the selected keyboard text input source.

@property(copy) NSString *selectedKeyboardInputSource;
Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

Class Methods

currentInputContext

Returns the current, activated, text input context object.

+ (NSTextInputContext *)currentInputContext;
Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

localizedNameForInputSource:

Returns the display name for the given text input source identifier.

+ (NSString *)localizedNameForInputSource:(NSString *)inputSourceIdentifier;
Parameters
inputSourceIdentifier

The text input source identifier.

Return Value

The localized display name for inputSourceIdentifier.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

Instance Methods

activate

Activates the receiver.

- (void)activate;
Discussion

You should not call this method directly; it is invoked by the system. It is provided as an override point for subclasses.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

deactivate

Deactivates the receiver.

- (void)deactivate;
Discussion

You should not call this method directly; it is invoked by the system. It is provided as an override point for subclasses.

Availability
  • Available in OS X v10.6 and later.
See Also
Declared In
NSTextInputContext.h

discardMarkedText

Tells the Cocoa test input system to discard the current conversion session.

- (void)discardMarkedText;
Discussion

The client should clear its marked range when sending this message.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

handleEvent:

Tells the Cocoa text input system to handle mouse or key events.

- (BOOL)handleEvent:(NSEvent *)theEvent;
Parameters
theEvent

The event to handle.

Return Value

YES if the system consumed the event; otherwise NO.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

initWithClient:

The designated initializer

- (id)initWithClient:(id <NSTextInputClient>)theClient;
Availability
  • Available in OS X v10.6 and later.
Declared In
NSTextInputContext.h

invalidateCharacterCoordinates

Notifies the Cocoa text input system that the position information previously queried via methods like firstRectForCharacterRange:actualRange: needs to be updated.

- (void)invalidateCharacterCoordinates;
Availability
  • Available in OS X v10.6 and later.
Related Sample Code
Declared In
NSTextInputContext.h

Notifications

NSTextInputContextKeyboardSelectionDidChangeNotification

Posted after the selected text input source changes.
Availability
Declared In
NSTextInputContext.h