<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextInputContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextInputContext"
  },
  "title" : "NSTextInputContext"
}
-->

# NSTextInputContext

An object that represents the Cocoa text input system.

```
class NSTextInputContext
```

## Overview

The text input system communicates primarily with the client of the activated input context via the [`NSTextInputClient`](/documentation/AppKit/NSTextInputClient) protocol.

## Topics

### Creating an Input Context

[`init(client:)`](/documentation/AppKit/NSTextInputContext/init(client:))

The designated initializer

### Getting the Input Context and Client

[`current`](/documentation/AppKit/NSTextInputContext/current)

Returns the current, activated, text input context object.

[`client`](/documentation/AppKit/NSTextInputContext/client)

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

### Configuring the Input Context

[`acceptsGlyphInfo`](/documentation/AppKit/NSTextInputContext/acceptsGlyphInfo)

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

[`allowedInputSourceLocales`](/documentation/AppKit/NSTextInputContext/allowedInputSourceLocales)

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

### Activating the Input Context

[`activate()`](/documentation/AppKit/NSTextInputContext/activate())

Activates the receiver.

[`deactivate()`](/documentation/AppKit/NSTextInputContext/deactivate())

Deactivates the receiver.

### Handling Input Sources

[`handleEvent(_:)`](/documentation/AppKit/NSTextInputContext/handleEvent(_:))

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

[`discardMarkedText()`](/documentation/AppKit/NSTextInputContext/discardMarkedText())

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

[`invalidateCharacterCoordinates()`](/documentation/AppKit/NSTextInputContext/invalidateCharacterCoordinates())

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

[`keyboardInputSources`](/documentation/AppKit/NSTextInputContext/keyboardInputSources)

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

[`selectedKeyboardInputSource`](/documentation/AppKit/NSTextInputContext/selectedKeyboardInputSource)

The identifier string for the selected keyboard text input source.

[`localizedName(forInputSource:)`](/documentation/AppKit/NSTextInputContext/localizedName(forInputSource:))

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

[`NSTextInputSourceIdentifier`](/documentation/AppKit/NSTextInputSourceIdentifier)

### Notifications

[`keyboardSelectionDidChangeNotification`](/documentation/AppKit/NSTextInputContext/keyboardSelectionDidChangeNotification)

Posted after the selected text input source changes.

### Instance Methods

[`textInputClientDidEndScrollingOrZooming()`](/documentation/AppKit/NSTextInputContext/textInputClientDidEndScrollingOrZooming())

[`textInputClientWillStartScrollingOrZooming()`](/documentation/AppKit/NSTextInputContext/textInputClientWillStartScrollingOrZooming())



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)