參考資料:
[1] mac上使用qt,進行輸入法的開發 http://blog.csdn.net/dinjay/article/details/7468268
[2] Swift 使用 InputMethodKit 寫輸入法 https://www.logcg.com/archives/2078.html
[3] InputMethodKit https://developer.apple.com/reference/inputmethodkit
[4] Mac 示例 http://developer.apple.com/library/mac/#samplecode/NumberInput_IMKit_Sample/Introduction/Intro.html
[5] StackOverflow : http://stackoverflow.com/questions/27813151/how-to-develop-a-simple-input-method-for-mac-os-x-in-swift
步驟:
1. 在Xcode中,創建一個PRoject,類型是 Cocoa application,按照[2]的建議命名:
在 Product Name 里填寫: YourAppName
在 Orgnization Identifier 里填寫: com.YourName.inputmethode
于是,你的APP的 Bundle Identifier 就是: com.YourName.inputmethod.YourAppName
2. 注意去掉所有勾,確認,創建工程。
3. 然后進入工程,刪除有關界面的項目,包括窗口和MainMenu。
4. 在plist里,添加一些項目,與[4] Mac 示例里的完全一致,其中有些值按照[2]的建議填寫。這些項目是:
Application is background only(自帶項目)= YES
InputMethodConnectionName = YourConnectionName(詳見示例代碼,[2][5])
InputMethodServerControllerClass = $(PRODUCT_MODULE_NAME).YourClassName(其中,YourClassName 是要添加的類名)
tsInputMethodIconFileKey = YourIcon.tiff
tsInputMethodCharacterRepertoireKey 類型為Array,其中新建項目 Item 0 = Latn
5. 在工程里,新建類 YourClassName,按[2]的示例代碼,編譯。注意,[5]是正確的代碼。
6. 把編譯好的App拷貝到系統的資源庫/InputMethod(Finder,前往,按住Option鍵,即可出現資源庫選項)里,然后就可以在系統輸入法里添加了。
新聞熱點
疑難解答