KeyHandler // Switch candidates by Shift(+CMD)+Space.
This commit is contained in:
parent
d2da05a267
commit
ab62321f7a
|
@ -247,7 +247,7 @@ extension KeyHandler {
|
||||||
{
|
{
|
||||||
if input.isSpace {
|
if input.isSpace {
|
||||||
// If the Space key is NOT set to be a selection key
|
// If the Space key is NOT set to be a selection key
|
||||||
if input.isShiftHold || !mgrPrefs.chooseCandidateUsingSpace {
|
if !mgrPrefs.chooseCandidateUsingSpace {
|
||||||
if compositorCursorIndex >= compositorLength {
|
if compositorCursorIndex >= compositorLength {
|
||||||
let composingBuffer = currentState.composingBuffer
|
let composingBuffer = currentState.composingBuffer
|
||||||
if !composingBuffer.isEmpty {
|
if !composingBuffer.isEmpty {
|
||||||
|
@ -264,6 +264,11 @@ extension KeyHandler {
|
||||||
stateCallback(inputting)
|
stateCallback(inputting)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
} else if input.isShiftHold { // 臉書等網站會攔截 Tab 鍵,所以用 Shift+CMD+Space 對候選字詞做正向/反向輪替。
|
||||||
|
return handleInlineCandidateRotation(
|
||||||
|
state: state, reverseModifier: input.isCommandHold, stateCallback: stateCallback,
|
||||||
|
errorCallback: errorCallback
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateCallback(buildCandidate(state: currentState, isTypingVertical: input.isTypingVertical))
|
stateCallback(buildCandidate(state: currentState, isTypingVertical: input.isTypingVertical))
|
||||||
|
@ -279,8 +284,8 @@ extension KeyHandler {
|
||||||
// MARK: Tab
|
// MARK: Tab
|
||||||
|
|
||||||
if input.isTab {
|
if input.isTab {
|
||||||
return handleTab(
|
return handleInlineCandidateRotation(
|
||||||
state: state, isShiftHold: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback
|
state: state, reverseModifier: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,11 +642,11 @@ extension KeyHandler {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 處理 Tab 按鍵行為
|
// MARK: - 處理上下文候選字詞輪替(Tab 按鍵,或者 Shift+Space)
|
||||||
|
|
||||||
func handleTab(
|
func handleInlineCandidateRotation(
|
||||||
state: InputState,
|
state: InputState,
|
||||||
isShiftHold: Bool,
|
reverseModifier: Bool,
|
||||||
stateCallback: @escaping (InputState) -> Void,
|
stateCallback: @escaping (InputState) -> Void,
|
||||||
errorCallback: @escaping () -> Void
|
errorCallback: @escaping () -> Void
|
||||||
) -> Bool {
|
) -> Bool {
|
||||||
|
@ -709,7 +709,7 @@ extension KeyHandler {
|
||||||
if candidates[0] == currentValue {
|
if candidates[0] == currentValue {
|
||||||
// If the first candidate is the value of the
|
// If the first candidate is the value of the
|
||||||
// current node, we use next one.
|
// current node, we use next one.
|
||||||
if isShiftHold {
|
if reverseModifier {
|
||||||
currentIndex = candidates.count - 1
|
currentIndex = candidates.count - 1
|
||||||
} else {
|
} else {
|
||||||
currentIndex = 1
|
currentIndex = 1
|
||||||
|
@ -718,7 +718,7 @@ extension KeyHandler {
|
||||||
} else {
|
} else {
|
||||||
for candidate in candidates {
|
for candidate in candidates {
|
||||||
if candidate == currentValue {
|
if candidate == currentValue {
|
||||||
if isShiftHold {
|
if reverseModifier {
|
||||||
if currentIndex == 0 {
|
if currentIndex == 0 {
|
||||||
currentIndex = candidates.count - 1
|
currentIndex = candidates.count - 1
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue