Skip to content

Commit 1a905a9

Browse files
committed
//IlimiInputController 不直接handle對candidates index的處理,交由candidateSelectionChange處理 #21
1 parent aa8b867 commit 1a905a9

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

Packages/ilimi_MainAssembly/Sources/ilimiMainAssembly/IlimiControllerEventHandler.swift

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -314,45 +314,35 @@ extension IlimiInputController {
314314
// 看起來不用特別分別對直式或橫式候選字窗做處理
315315
func handleCandidatesWindowNavigation(_ event: NSEvent, client sender: Any!) -> Bool {
316316
if let key = event.characters?.first {
317-
if key == "[" {
318-
candidates.moveUp(sender)
317+
if key == "<" {
318+
if SettingViewModel.shared.isHorizontalCandidatesPanel {
319+
candidates.moveUp(sender)
320+
} else {
321+
candidates.moveLeft(sender)
322+
}
319323
return true
320-
} else if key == "]" {
321-
candidates.moveDown(sender)
324+
} else if key == ">" {
325+
if SettingViewModel.shared.isHorizontalCandidatesPanel {
326+
candidates.moveDown(sender)
327+
} else {
328+
candidates.moveRight(sender)
329+
}
322330
return true
323331
}
324332
}
325333
// 即使已經在最左或最右也要攔截左﹑右方向鍵事件。否則輸入法會在再次按下方向鍵時卡死
326334
var isArrow = false
327335
if event.keyCode == kVK_RightArrow {
328-
if InputContext.shared.currentIndex < InputContext.shared.candidatesCount - 1 {
329-
// InputContext.shared.currentIndex += 1
330-
candidates.moveRight(sender)
331-
}
336+
candidates.moveRight(sender)
332337
isArrow = true
333338
} else if event.keyCode == kVK_LeftArrow {
334-
if InputContext.shared.currentIndex > 0 {
335-
// InputContext.shared.currentIndex -= 1
336-
candidates.moveLeft(sender)
337-
}
339+
candidates.moveLeft(sender)
338340
isArrow = true
339341
} else if event.keyCode == kVK_UpArrow {
340342
candidates.moveUp(sender)
341-
if InputContext.shared.candidatesPageId > 0 {
342-
// if InputContext.shared.candidatesPageId > 1 {
343-
// InputContext.shared.currentIndex -= 5
344-
// }
345-
InputContext.shared.candidatesPageId -= 1
346-
}
347343
isArrow = true
348344
} else if event.keyCode == kVK_DownArrow {
349345
candidates.moveDown(sender)
350-
if InputContext.shared.candidatesPageId < InputContext.shared.candidatesPagesCount {
351-
// if InputContext.shared.candidatesPageId > 0 {
352-
// InputContext.shared.currentIndex += 5
353-
// }
354-
InputContext.shared.candidatesPageId += 1
355-
}
356346
isArrow = true
357347
}
358348
return isArrow

Packages/ilimi_MainAssembly/Sources/ilimiMainAssembly/IlimiInputController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public class IlimiInputController: IMKInputController {
7171

7272
override public func candidateSelected(_ candidateString: NSAttributedString!) {
7373
let id = findCandidateIndex(candidateString)
74-
NSLog("id: \(id), candidate: \(candidateString.string)")
7574
InputContext.shared.currentIndex = id
7675
commitCandidate(client: client())
7776
}

0 commit comments

Comments
 (0)