CtlCandidateTDK // DIfferentiate page flipping and row flipping.

This commit is contained in:
ShikiSuen 2022-09-28 23:56:12 +08:00
parent b38938de54
commit cef1a2a3f5
2 changed files with 58 additions and 7 deletions

View File

@ -65,12 +65,28 @@ public class CtlCandidateTDK: CtlCandidate {
} }
@discardableResult override public func showNextPage() -> Bool { @discardableResult override public func showNextPage() -> Bool {
thePool.selectNewNeighborRow(direction: .down) for _ in 0..<6 {
thePool.selectNewNeighborRow(direction: .down)
}
updateDisplay() updateDisplay()
return true return true
} }
@discardableResult override public func showPreviousPage() -> Bool { @discardableResult override public func showPreviousPage() -> Bool {
for _ in 0..<6 {
thePool.selectNewNeighborRow(direction: .up)
}
updateDisplay()
return true
}
@discardableResult public func showNextLine() -> Bool {
thePool.selectNewNeighborRow(direction: .down)
updateDisplay()
return true
}
@discardableResult public func showPreviousLine() -> Bool {
thePool.selectNewNeighborRow(direction: .up) thePool.selectNewNeighborRow(direction: .up)
updateDisplay() updateDisplay()
return true return true

View File

@ -8,6 +8,7 @@
/// 調 /// 調
import CandidateWindow
import Shared import Shared
// MARK: - § 調 (Handle Candidate State). // MARK: - § 調 (Handle Candidate State).
@ -162,8 +163,21 @@ extension KeyHandler {
if input.isUp { if input.isUp {
switch ctlCandidate.currentLayout { switch ctlCandidate.currentLayout {
case .horizontal: case .horizontal:
if !ctlCandidate.showPreviousPage() { if #available(macOS 12, *) {
errorCallback("9B614524") if let ctlCandidate = ctlCandidate as? CtlCandidateTDK {
ctlCandidate.showPreviousLine()
break
} else {
if !ctlCandidate.showPreviousPage() {
errorCallback("9B614524")
break
}
}
} else {
if !ctlCandidate.showPreviousPage() {
errorCallback("9B614524")
break
}
} }
case .vertical: case .vertical:
if !ctlCandidate.highlightPreviousCandidate() { if !ctlCandidate.highlightPreviousCandidate() {
@ -180,8 +194,21 @@ extension KeyHandler {
if input.isDown { if input.isDown {
switch ctlCandidate.currentLayout { switch ctlCandidate.currentLayout {
case .horizontal: case .horizontal:
if !ctlCandidate.showNextPage() { if #available(macOS 12, *) {
errorCallback("92B990DD") if let ctlCandidate = ctlCandidate as? CtlCandidateTDK {
ctlCandidate.showNextLine()
break
} else {
if !ctlCandidate.showNextPage() {
errorCallback("92B990DD")
break
}
}
} else {
if !ctlCandidate.showNextPage() {
errorCallback("92B990DD")
break
}
} }
case .vertical: case .vertical:
if !ctlCandidate.highlightNextCandidate() { if !ctlCandidate.highlightNextCandidate() {
@ -294,8 +321,16 @@ extension KeyHandler {
// MARK: - Flipping pages by using symbol menu keys (when they are not occupied). // MARK: - Flipping pages by using symbol menu keys (when they are not occupied).
if input.isSymbolMenuPhysicalKey { if input.isSymbolMenuPhysicalKey {
let updated: Bool = var updated = true
input.isShiftHold ? ctlCandidate.showPreviousPage() : ctlCandidate.showNextPage() if #available(macOS 12, *) {
if let ctlCandidate = ctlCandidate as? CtlCandidateTDK {
updated = input.isShiftHold ? ctlCandidate.showPreviousLine() : ctlCandidate.showNextLine()
} else {
updated = input.isShiftHold ? ctlCandidate.showPreviousPage() : ctlCandidate.showNextPage()
}
} else {
updated = input.isShiftHold ? ctlCandidate.showPreviousPage() : ctlCandidate.showNextPage()
}
if !updated { if !updated {
errorCallback("66F3477B") errorCallback("66F3477B")
} }