The Input Method Kit (/System/Library/InputMethodKit.framework
) is a new Objective-C framework for building input methods for Chinese, Japanese, and other languages. This framework handles connecting to clients, running candidate windows, and various other tasks that, in the past, you needed to provide code for. By using the Input Method Kit, you are frees to focus exclusively on developing the core functionality of your input method product—the text conversion engine.
The support provided by the Input Method Kit is fairly simple. It uses just two, or optionally three, classes. You muse use the IMKServer
and the IMKInputController
class. If you want to use candidate windows, you also need to use the IMKCandidates
class.
How the Input Method Kit Works
For More Information
Every input method creates an IMKServer
object in its main function. One of the parameters for the IMKServer
object is a connection name. The IMKServer
object uses this name to create an NSConnection
object that clients use to connect to the input method. The only client in Mac OS X v10.5 is the Text Services Manager.
When a client requests an input session, the IMKServer
object allocates an IMKInputController
object or a class that inherits from IMKInputController
. This object then receives input from that client session. Note that IMKServer
creates a controller object for each session request. This frees you from the need to manage sessions; the IMKServer
object manages them for you. When a controller method is called, it is always from the same session.
You have several options for handling input from clients, each of which is discussed further in the IMKInputController.h
header file. The simplest approach is to write a delegate class that implements one of the methods for receiving input.
Another approach is to create a delegate class that handles input. Then you override IMKInputController
to take advantage of the utilities provided by that class.
For more information see:
These reference documents: IMKCandidates Class Reference, IMKInputController Class Reference, IMKServer Class Reference, IMKMouseHandling Protocol Reference, IMKServerInput Protocol Reference, IMKStateSetting Protocol Reference, and IMKTextInput Protocol Reference.
The documentation that is included with the BasicInputMethod and InputMethods sample code.
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-17)
|