Skip to content

Commit

Permalink
Also allows using arrow down key to choose candidates.
Browse files Browse the repository at this point in the history
  • Loading branch information
zonble committed Jul 19, 2022
1 parent 68026c5 commit e87e858
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Key.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace McBopomofo {
// This is not always a perfect representation (for example, shift muddles the
// picture), but is sufficient for KeyHandler's needs.
struct Key {
enum class KeyName { ASCII, LEFT, RIGHT, HOME, END, UNKNOWN };
enum class KeyName { ASCII, LEFT, RIGHT, UP, DOWN, HOME, END, UNKNOWN };

static constexpr char TAB = 9;
static constexpr char BACKSPACE = 8;
Expand Down
4 changes: 2 additions & 2 deletions src/KeyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ bool KeyHandler::handle(Key key, McBopomofo::InputState* state,

// Space hit: see if we should enter the candidate choosing state.
auto maybeNotEmptyState = dynamic_cast<InputStates::NotEmpty*>(state);
if (simpleAscii == Key::SPACE && maybeNotEmptyState != nullptr &&
reading_.isEmpty()) {
if ((simpleAscii == Key::SPACE || key.name == Key::KeyName::DOWN) &&
maybeNotEmptyState != nullptr && reading_.isEmpty()) {
stateCallback(buildChoosingCandidateState(maybeNotEmptyState));
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/McBopomofo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ static Key MapFcitxKey(const fcitx::Key& key) {
return Key::namedKey(Key::KeyName::HOME, shiftPressed, ctrlPressed);
case FcitxKey_End:
return Key::namedKey(Key::KeyName::END, shiftPressed, ctrlPressed);
case FcitxKey_Up:
return Key::namedKey(Key::KeyName::UP, shiftPressed, ctrlPressed);
case FcitxKey_Down:
return Key::namedKey(Key::KeyName::DOWN, shiftPressed, ctrlPressed);
default:
break;
}
Expand Down

0 comments on commit e87e858

Please sign in to comment.