KeyHandler // Simplifying the Enter-key Conditioning.
This commit is contained in:
parent
489385ae2b
commit
5fa40b5b42
|
@ -263,7 +263,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caps Lock processing : if Caps Lock is on, temporarily disable bopomofo.
|
// Caps Lock processing : if Caps Lock is on, temporarily disable bopomofo.
|
||||||
if ([input isBackSpace] || [input isEnterCharCode] || [input isEnter] || [input isAbsorbedArrowKey] || [input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] || [input isCursorForward] || [input isCursorBackward]) {
|
if ([input isBackSpace] || [input isEnter] || [input isAbsorbedArrowKey] || [input isExtraChooseCandidateKey] || [input isExtraChooseCandidateKeyReverse] || [input isCursorForward] || [input isCursorBackward]) {
|
||||||
// do nothing if backspace is pressed -- we ignore the key
|
// do nothing if backspace is pressed -- we ignore the key
|
||||||
} else if ([input isCapsLockOn]) {
|
} else if ([input isCapsLockOn]) {
|
||||||
// process all possible combination, we hope.
|
// process all possible combination, we hope.
|
||||||
|
@ -347,7 +347,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
|
|
||||||
// see if we have composition if Enter/Space is hit and buffer is not empty
|
// see if we have composition if Enter/Space is hit and buffer is not empty
|
||||||
// this is bit-OR'ed so that the tone marker key is also taken into account
|
// this is bit-OR'ed so that the tone marker key is also taken into account
|
||||||
composeReading |= (!_bpmfReadingBuffer->isEmpty() && ([input isSpace] || [input isEnterCharCode] || [input isEnter]));
|
composeReading |= (!_bpmfReadingBuffer->isEmpty() && ([input isSpace] || [input isEnter]));
|
||||||
if (composeReading) {
|
if (composeReading) {
|
||||||
// combine the reading
|
// combine the reading
|
||||||
std::string reading = _bpmfReadingBuffer->syllable().composedString();
|
std::string reading = _bpmfReadingBuffer->syllable().composedString();
|
||||||
|
@ -506,7 +506,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Enter
|
// MARK: Enter
|
||||||
if ([input isEnter] || [input isEnterCharCode]) {
|
if ([input isEnter]) {
|
||||||
if ([input isControlHold]) {
|
if ([input isControlHold]) {
|
||||||
if (ctlInputMethod.areWeUsingOurOwnPhraseEditor) {
|
if (ctlInputMethod.areWeUsingOurOwnPhraseEditor) {
|
||||||
return [self _handleCtrlEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback];
|
return [self _handleCtrlEnterWithState:state stateCallback:stateCallback errorCallback:errorCallback];
|
||||||
|
@ -918,7 +918,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enter
|
// Enter
|
||||||
if ([input isEnter] || [input isEnterCharCode]) {
|
if ([input isEnter]) {
|
||||||
if (![self.delegate keyHandler:self didRequestWriteUserPhraseWithState:state]) {
|
if (![self.delegate keyHandler:self didRequestWriteUserPhraseWithState:state]) {
|
||||||
[self errorCallbackConsolePrint:@"5B69CC8D"];
|
[self errorCallbackConsolePrint:@"5B69CC8D"];
|
||||||
errorCallback();
|
errorCallback();
|
||||||
|
@ -1013,7 +1013,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([input isEnterCharCode] || [input isEnter]) {
|
if ([input isEnter]) {
|
||||||
if ([state isKindOfClass: [InputStateAssociatedPhrases class]]) {
|
if ([state isKindOfClass: [InputStateAssociatedPhrases class]]) {
|
||||||
[self clear];
|
[self clear];
|
||||||
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
|
||||||
|
|
|
@ -144,11 +144,7 @@ class KeyHandlerInput: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc var isEnter: Bool {
|
@objc var isEnter: Bool {
|
||||||
KeyCode(rawValue: keyCode) == KeyCode.enter
|
(CharCode(rawValue: charCode) == CharCode.enter) || (KeyCode(rawValue: keyCode) == KeyCode.enter)
|
||||||
}
|
|
||||||
|
|
||||||
@objc var isEnterCharCode: Bool {
|
|
||||||
CharCode(rawValue: charCode) == CharCode.enter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc var isUp: Bool {
|
@objc var isUp: Bool {
|
||||||
|
|
Loading…
Reference in New Issue