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

# IMKInputController

The `IMKInputController` class provides a base class for custom input controller classes. The [`IMKServer`](/documentation/InputMethodKit/IMKServer)  class, which is allocated in the main function of an input method, creates an input controller object for each input session created by a client application. For every input session there is a corresponding `IMKInputController` object.

```
class IMKInputController
```

## Overview

An `IMKInputController` object controls text input on the input method side. It manages events and text from the applications and converted text from the input method engine. `IMKInputController` implements fully the [`IMKStateSetting`](/documentation/InputMethodKit/IMKStateSetting) and [`IMKMouseHandling`](/documentation/InputMethodKit/IMKMouseHandling) protocols.  Typically you do not need to override this class, but you do need to provide  a delegate object that implements the methods that your are interested in.  The `IMKInputController` versions of the protocol methods check whether the delegate object implements a method, and  calls the delegate version if it exists.

## Topics

### Initializing an Input Controller

[`-  initWithServer:delegate:client:`](/documentation/InputMethodKit/IMKInputController/init(server:delegate:client:))

Initializes the input control by setting the delegate.

### Working with Ranges

[`-  compositionAttributesAtRange:`](/documentation/InputMethodKit/IMKInputController/compositionAttributes(at:))

Returns a dictionary of text attributes.

[`-  selectionRange`](/documentation/InputMethodKit/IMKInputController/selectionRange())

Returns where the range of the selection that should be placed inside marked text.

[`-  replacementRange`](/documentation/InputMethodKit/IMKInputController/replacementRange())

Returns the range in the client document that the text should replace.

[`-  markForStyle:atRange:`](/documentation/InputMethodKit/IMKInputController/mark(forStyle:at:))

Returns a dictionary of text attributes that can mark a range of an attributed string to send to a client.

### Managing the Delegate

[`-  delegate`](/documentation/InputMethodKit/IMKInputController/delegate())

Returns the delegate for input controller  object.

[`-  setDelegate:`](/documentation/InputMethodKit/IMKInputController/setDelegate(_:))

Sets the delegate for input controller  object.

### Getting the Client and Server Objects

[`-  server`](/documentation/InputMethodKit/IMKInputController/server())

Returns the server object that manages the input controller.

[`-  client`](/documentation/InputMethodKit/IMKInputController/client())

Returns the client object associated with the input controller.

### Tracking Selections

[`-  annotationSelected:forCandidate:`](/documentation/InputMethodKit/IMKInputController/annotationSelected(_:forCandidate:))

Sends the selected candidate string and annotation string to the input controller.

[`-  candidateSelectionChanged:`](/documentation/InputMethodKit/IMKInputController/candidateSelectionChanged(_:))

Informs an input controller that the current candidate selection in the candidate window has changed.

[`-  candidateSelected:`](/documentation/InputMethodKit/IMKInputController/candidateSelected(_:))

Informs an input controller that a new candidate is selected.

### Managing Composition

[`-  updateComposition`](/documentation/InputMethodKit/IMKInputController/updateComposition())

Informs the input controller that the composition has changed.

[`-  cancelComposition`](/documentation/InputMethodKit/IMKInputController/cancelComposition())

Stops the current composition and replaces marked text with the original text.

### Hiding the User Interface

[`-  hidePalettes`](/documentation/InputMethodKit/IMKInputController/hidePalettes())

Informs an input method that it should  close any visible user interface.

### Working with Custom Commands

[`-  doCommandBySelector:commandDictionary:`](/documentation/InputMethodKit/IMKInputController/doCommand(by:command:))

Passes commands that are not generated as part of the text input process.

[`-  menu`](/documentation/InputMethodKit/IMKInputController/menu())

Returns a menu of commands that are specific to an input method.

### Instance Methods

[`-  inputControllerWillClose`](/documentation/InputMethodKit/IMKInputController/inputControllerWillClose())

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`IMKMouseHandling`](/documentation/InputMethodKit/IMKMouseHandling)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`IMKStateSetting`](/documentation/InputMethodKit/IMKStateSetting)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)