InputHandler // Ensure commission of existing contents in certain cases. (#198)
- This fixes #194 and #195.
This commit is contained in:
parent
56a955c47c
commit
5465fe16d2
|
@ -69,6 +69,12 @@ extension IMEState {
|
||||||
public static func ofDeactivated() -> IMEState { .init(type: .ofDeactivated) }
|
public static func ofDeactivated() -> IMEState { .init(type: .ofDeactivated) }
|
||||||
public static func ofEmpty() -> IMEState { .init(type: .ofEmpty) }
|
public static func ofEmpty() -> IMEState { .init(type: .ofEmpty) }
|
||||||
public static func ofAbortion() -> IMEState { .init(type: .ofAbortion) }
|
public static func ofAbortion() -> IMEState { .init(type: .ofAbortion) }
|
||||||
|
|
||||||
|
/// 用以手動遞交指定內容的狀態。
|
||||||
|
/// - Remark: 直接切換至該狀態的話,會丟失上一個狀態的內容。
|
||||||
|
/// 如不想丟失的話,請先切換至 `.ofEmpty()` 再切換至 `.ofCommitting()`。
|
||||||
|
/// - Parameter textToCommit: 要遞交的文本。
|
||||||
|
/// - Returns: 要切換到的狀態。
|
||||||
public static func ofCommitting(textToCommit: String) -> IMEState {
|
public static func ofCommitting(textToCommit: String) -> IMEState {
|
||||||
var result = IMEState(type: .ofCommitting)
|
var result = IMEState(type: .ofCommitting)
|
||||||
result.textToCommit = textToCommit
|
result.textToCommit = textToCommit
|
||||||
|
|
|
@ -80,6 +80,7 @@ extension InputHandler {
|
||||||
// 我們先規定允許小鍵盤區域操縱選字窗,其餘場合一律直接放行。
|
// 我們先規定允許小鍵盤區域操縱選字窗,其餘場合一律直接放行。
|
||||||
if input.isNumericPadKey {
|
if input.isNumericPadKey {
|
||||||
if ![.ofCandidates, .ofAssociates, .ofSymbolTable].contains(state.type) {
|
if ![.ofCandidates, .ofAssociates, .ofSymbolTable].contains(state.type) {
|
||||||
|
delegate.switchState(IMEState.ofEmpty())
|
||||||
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
|
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -247,9 +248,11 @@ extension InputHandler {
|
||||||
if input.isShiftHold { // 這裡先不要判斷 isOptionHold。
|
if input.isShiftHold { // 這裡先不要判斷 isOptionHold。
|
||||||
switch prefs.upperCaseLetterKeyBehavior {
|
switch prefs.upperCaseLetterKeyBehavior {
|
||||||
case 1:
|
case 1:
|
||||||
|
delegate.switchState(IMEState.ofEmpty())
|
||||||
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
|
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.lowercased()))
|
||||||
return true
|
return true
|
||||||
case 2:
|
case 2:
|
||||||
|
delegate.switchState(IMEState.ofEmpty())
|
||||||
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.uppercased()))
|
delegate.switchState(IMEState.ofCommitting(textToCommit: inputText.uppercased()))
|
||||||
return true
|
return true
|
||||||
default: // 包括 case 0,直接塞給組字區。
|
default: // 包括 case 0,直接塞給組字區。
|
||||||
|
|
Loading…
Reference in New Issue