我知道有一個API reference for the InputMethodKit framework。 Objective-C中也有sample code,但它沒有在Swift中提供示例。如何在Swift中爲Mac OS X開發一個簡單的輸入法?
有誰知道如何在Swift中製作簡單的IME?它可以具有像重複這封信一樣的功能,但只是不做任何事情,所以我可以知道它確實有效。使用哪個Xcode SDK構建它併成功運行它?
我知道有一個API reference for the InputMethodKit framework。 Objective-C中也有sample code,但它沒有在Swift中提供示例。如何在Swift中爲Mac OS X開發一個簡單的輸入法?
有誰知道如何在Swift中製作簡單的IME?它可以具有像重複這封信一樣的功能,但只是不做任何事情,所以我可以知道它確實有效。使用哪個Xcode SDK構建它併成功運行它?
我上傳Apple's NumberInput
sample code到GitHub庫,方便易讀:
https://github.com/pkamb/NumberInput_IMKit_Sample
具體來說,我已經上傳的樣本項目示範爲自己的git的承諾每個「臺階」。這樣可以更輕鬆地區分項目工作流程。請繼續查看他們如何向示例輸入法項目添加功能。
我也試圖Apple's IMKit sample第一部分「NumberInput 0」 Objective-C的項目轉換爲雨燕
如果「NumberInput 0」斯威夫特項目工程,然後按照NumberInput 1,2,3能迅速轉化。
Swift項目中的「NumberInput 0」可以被編譯,安裝,添加到輸入源,可以被選擇和運行,但是當輸入鍵時IMKInputController子類NumberInputController的方法inputText(...)無法到達我使用的Xcode調試NumberInput.app
NumberInput 0是簡單地僅包括4個文件,幾行代碼:
NumberInputController被列在info.plist中。
我已經用Xcode 7成功地重新創建了使用Objective-C的「NumberInput 0」項目,所有工作,NumberInputController函數inputText(...)都可以通過在調試時輸入鍵來實現。
我是Swift的新手,任何人都可以幫助我在Swift中獲得「NumberInput 0」嗎?
下面是3個文件的內容:NumberInputController.swift
import Cocoa
import InputMethodKit
class NumberInputController: IMKInputController {
override func inputText(string:String, client: AnyObject) ->Bool {
// Debug break point put here
print(string);
return false;
}
}
信息
AppDelegate.swift
。plist中
...
<dict>
\t ....
<key>NSMainNibFile</key>
\t <string>MainMenu</string>
\t <key>NSPrincipalClass</key>
\t <string>NSApplication</string>
\t <key>LSBackgroundOnly</key>
\t <string>1</string>
\t <key>InputMethodConnectionName</key>
\t <string>NumberInput_1_Connection</string>
\t <key>InputMethodServerControllerClass</key>
\t <string>NumberInputController</string>
\t <key>tsInputMethodIconFileKey</key>
\t <string>nine.tiff</string>
\t <key>tsInputMethodCharacterRepertoireKey</key>
\t <array>
\t \t <string>Latn</string>
\t </array>
</dict>
</plist>
感謝。
基於輸入法套件框架,我在Objective-c中開發了一個全功能的輸入法,並在GitHub上共享:https://github.com/HeChinese/OpenHeInput-MacOS – heMac
請注意,這不是「答案」,因爲它這不是一個有效的例子,所以這個問題仍然沒有答案。 –
Pkamb的項目仍然在objective-c中,而不是在Swift中。 – heMac