Skip to content

Commit

Permalink
Makes it able to use the keys on the numpad to select candidates.
Browse files Browse the repository at this point in the history
  • Loading branch information
zonble committed Jul 31, 2024
1 parent 19fdf26 commit 6c80eea
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/McBopomofo.cpp
Original file line number Diff line number Diff line change
@@ -725,9 +725,14 @@ bool McBopomofoEngine::handleCandidateKeyEvent(
}
return true;
}

} else {
// handle num pad.

int idx = key.keyListIndex(selectionKeys_);
if (idx == -1) {
idx = key.keyListIndex(numpadSelectionKeys_);
}

if (idx != -1 && idx < candidateList->size()) {
#ifdef USE_LEGACY_FCITX5_API
candidateList->candidate(idx)->select(context);
@@ -1182,10 +1187,22 @@ void McBopomofoEngine::handleCandidatesState(fcitx::InputContext* context,
} else {
if (keysConfig == SelectionKeys::Key_asdfghjkl) {
selectionKeys_ = fcitx::Key::keyListFromString("a s d f g h j k l");
numpadSelectionKeys_ = fcitx::KeyList();
} else if (keysConfig == SelectionKeys::Key_asdfzxcvb) {
selectionKeys_ = fcitx::Key::keyListFromString("a s d f z x c v b");
numpadSelectionKeys_ = fcitx::KeyList();
} else {
selectionKeys_ = fcitx::Key::keyListFromString("1 2 3 4 5 6 7 8 9");
numpadSelectionKeys_ = fcitx::KeyList();
numpadSelectionKeys_.emplace_back(FcitxKey_KP_1);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_2);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_3);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_4);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_5);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_6);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_7);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_8);
numpadSelectionKeys_.emplace_back(FcitxKey_KP_9);
}
}
candidateList->setSelectionKey(selectionKeys_);
1 change: 1 addition & 0 deletions src/McBopomofo.h
Original file line number Diff line number Diff line change
@@ -232,6 +232,7 @@ class McBopomofoEngine : public fcitx::InputMethodEngine {
std::unique_ptr<InputState> state_;
McBopomofoConfig config_;
fcitx::KeyList selectionKeys_;
fcitx::KeyList numpadSelectionKeys_;

std::unique_ptr<fcitx::SimpleAction> halfWidthPunctuationAction_;
std::unique_ptr<fcitx::SimpleAction> associatedPhrasesAction_;

0 comments on commit 6c80eea

Please sign in to comment.