Objective-c – OSX “Input Methods” accessed through Objective-C

objective c

I'm trying to make use of OSX's input methods, specifically Cangjie and Pinyin, in an OSX application. Basically, what I want to do is to switch the input method to Cangjie upon entering a text field. The user can now use Cangjie to input Characters in Traditional Chinese. Upon leaving this text field, I want to use the other input methods (Jyutping and Pinyin) to find the characters pronunciation. This should be possible – there is a little tool provided by Apple, called TCIMTool, that can be opened by choosing "Find Input Code" under the Cangjie input menu, that does exactly this – you enter a Chinese Character and it displays the input code for Pinyin (and some others).

I tried to find anything about this in the XCode documentation but so far to no avail. Any help would be most appreciated 🙂

Best Answer

Check out:

  1. The Input Method Framework.
  2. More specifically, the selectInputMode method of the IMKTextInput class.
  3. On related subjects, you might find this Technical Note helpful.

The mode identifier you need to provide to the selectInputMode method is described as:

An NSString object with a DNS format, such as: com.company name .inputmethod.some name. The identifier should match one of the keys in the component input mode dictionary.

So if you can get the key for the Cangjie entry in the component input mode dictionary, you should be home free.

I've tried to search for this, but with no luck. Hopefully you'll know where to look for this. Maybe in the plist for your application?