Skip to content

Commit

Permalink
Merge pull request #203 from chewing/feat-show-chieng-mode
Browse files Browse the repository at this point in the history
fix: shift key handling
  • Loading branch information
kanru authored Nov 4, 2024
2 parents 3f55030 + 806fc9a commit aac6adb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ChewingTextService/ChewingTextService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,23 +435,22 @@ bool TextService::onKeyDown(Ime::KeyEvent& keyEvent, Ime::EditSession* session)

// virtual
bool TextService::filterKeyUp(Ime::KeyEvent& keyEvent) {
bool shouldHandle = false;
if(config().switchLangWithShift) {
if(lastKeyDownCode_ == VK_SHIFT && keyEvent.keyCode() == VK_SHIFT) {
if (lastKeyDownCode_ == VK_SHIFT && keyEvent.keyCode() == VK_SHIFT) {
// last key down event is also shift key
// a <Shift> key down + key up pair was detected
// switch language
shouldHandle = true;
return true;
}
}
lastKeyDownCode_ = 0;
return shouldHandle;
return false;
}

// virtual
bool TextService::onKeyUp(Ime::KeyEvent& keyEvent, Ime::EditSession* session) {
if(config().switchLangWithShift) {
if(lastKeyDownCode_ == 0 && keyEvent.keyCode() == VK_SHIFT) {
if (lastKeyDownCode_ == VK_SHIFT && keyEvent.keyCode() == VK_SHIFT) {
toggleLanguageMode(session);
std::wstring msg;
if (chewing_get_ChiEngMode(chewingContext_) == SYMBOL_MODE) {
Expand All @@ -462,6 +461,7 @@ bool TextService::onKeyUp(Ime::KeyEvent& keyEvent, Ime::EditSession* session) {
showMessage(session, msg, 2);
}
}
lastKeyDownCode_ = 0;
return true;
}

Expand Down

0 comments on commit aac6adb

Please sign in to comment.