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 the Space key is NOT set to be a selection key
|
||||
if input.isShiftHold || !mgrPrefs.chooseCandidateUsingSpace {
|
||||
if !mgrPrefs.chooseCandidateUsingSpace {
|
||||
if compositorCursorIndex >= compositorLength {
|
||||
let composingBuffer = currentState.composingBuffer
|
||||
if !composingBuffer.isEmpty {
|
||||
|
@ -264,6 +264,11 @@ extension KeyHandler {
|
|||
stateCallback(inputting)
|
||||
}
|
||||
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))
|
||||
|
@ -279,8 +284,8 @@ extension KeyHandler {
|
|||
// MARK: Tab
|
||||
|
||||
if input.isTab {
|
||||
return handleTab(
|
||||
state: state, isShiftHold: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback
|
||||
return handleInlineCandidateRotation(
|
||||
state: state, reverseModifier: input.isShiftHold, stateCallback: stateCallback, errorCallback: errorCallback
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -642,11 +642,11 @@ extension KeyHandler {
|
|||
return true
|
||||
}
|
||||
|
||||
// MARK: - 處理 Tab 按鍵行為
|
||||
// MARK: - 處理上下文候選字詞輪替(Tab 按鍵,或者 Shift+Space)
|
||||
|
||||
func handleTab(
|
||||
func handleInlineCandidateRotation(
|
||||
state: InputState,
|
||||
isShiftHold: Bool,
|
||||
reverseModifier: Bool,
|
||||
stateCallback: @escaping (InputState) -> Void,
|
||||
errorCallback: @escaping () -> Void
|
||||
) -> Bool {
|
||||
|
@ -709,7 +709,7 @@ extension KeyHandler {
|
|||
if candidates[0] == currentValue {
|
||||
// If the first candidate is the value of the
|
||||
// current node, we use next one.
|
||||
if isShiftHold {
|
||||
if reverseModifier {
|
||||
currentIndex = candidates.count - 1
|
||||
} else {
|
||||
currentIndex = 1
|
||||
|
@ -718,7 +718,7 @@ extension KeyHandler {
|
|||
} else {
|
||||
for candidate in candidates {
|
||||
if candidate == currentValue {
|
||||
if isShiftHold {
|
||||
if reverseModifier {
|
||||
if currentIndex == 0 {
|
||||
currentIndex = candidates.count - 1
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue