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 {
thePool.selectNewNeighborRow(direction: .down)
for _ in 0..<6 {
thePool.selectNewNeighborRow(direction: .down)
}
updateDisplay()
return true
}
@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)
updateDisplay()
return true

View File

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