ctlIME // Simplify handleDelegateEvent().

This commit is contained in:
ShikiSuen 2022-08-04 08:11:30 +08:00
parent a91f0ea421
commit 54d2fb4fc5
1 changed files with 1 additions and 46 deletions

View File

@ -54,52 +54,7 @@ extension ctlInputMethod: KeyHandlerDelegate {
// MARK: - Candidate Controller Delegate
extension ctlInputMethod: ctlCandidateDelegate {
func handleDelegateEvent(_ event: NSEvent!) -> Bool {
/// flags使 KeyHandler
/// flags
/// event.type == .flagsChanged return false
/// NSInternalInconsistencyException
if event.type == .flagsChanged {
return false
}
// Enter
ctlInputMethod.areWeDeleting = event.modifierFlags.contains([.shift, .command])
var textFrame = NSRect.zero
let attributes: [AnyHashable: Any]? = client().attributes(
forCharacterIndex: 0, lineHeightRectangle: &textFrame
)
let isTypingVertical =
(attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false
if client().bundleIdentifier()
== "org.atelierInmu.vChewing.vChewingPhraseEditor"
{
IME.areWeUsingOurOwnPhraseEditor = true
} else {
IME.areWeUsingOurOwnPhraseEditor = false
}
let input = InputSignal(event: event, isVerticalTyping: isTypingVertical)
//
// KeyHandler
if !input.charCode.isPrintable {
return false
}
/// 調
/// result bool IMK
let result = keyHandler.handleCandidate(state: state, input: input) { newState in
self.handle(state: newState)
} errorCallback: {
clsSFX.beep()
}
return result
}
func handleDelegateEvent(_ event: NSEvent!) -> Bool { handle(event, client: client()) }
func candidateCountForController(_ controller: ctlCandidateProtocol) -> Int {
_ = controller //