2015-01-07 74 views

回答

-1

我也試圖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個文件,幾行代碼:

  1. AppDelegate.swift
  2. NumberInputController.swift
  3. MainMenu.xib
  4. 的Info.plist

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>

感謝。

+0

基於輸入法套件框架,我在Objective-c中開發了一個全功能的輸入法,並在GitHub上共享:https://github.com/HeChinese/OpenHeInput-MacOS – heMac

+0

請注意,這不是「答案」,因爲它這不是一個有效的例子,所以這個問題仍然沒有答案。 –