Skip to content

Commit

Permalink
Merge pull request #1 from Wedge009/Wedge009-hotkey-fix
Browse files Browse the repository at this point in the history
Correct handling of Ctrl+Return/Enter hot-key.
  • Loading branch information
Wedge009 committed Aug 13, 2015
2 parents a436c46 + b9d3fb6 commit 929ec99
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/hotkey/hotkey_item.cpp
Expand Up @@ -97,7 +97,11 @@ hotkey::hotkey_item& get_hotkey(int character, int keycode,
bool found = false;

for (itor = hotkeys_.begin(); itor != hotkeys_.end(); ++itor) {
if (itor->get_character() != -1) {
// Special case for Ctrl+Return/Enter keys, which gets resolved to Ctrl-j and Ctrl-m characters (LF and CR respectively).
// In such cases, do not match by character but go straight to key code.
if (itor->get_character() != -1 &&
!(tolower(character) == 'j' && keycode != SDLK_j) &&
!(tolower(character) == 'm' && keycode != SDLK_m)) {
if (character == itor->get_character()) {
if (ctrl == itor->get_ctrl()
&& cmd == itor->get_cmd()
Expand Down Expand Up @@ -532,7 +536,12 @@ void hotkey_item::set_key(int character, int keycode,
character -= 32; }

// We handle simple cases by character, others by the actual key.
if (isprint(character) && !isspace(character)) {
// @ and ` are exceptions related to the space character. Without these, combinations involving Ctrl or Ctrl+Shift often resolve the character value to null (or @ and `).
// j and m exceptions are to catch Ctrl+Return/Enter, which is interpreted as Ctrl+j and Ctrl+m characters (LF and CR respectively).
if (isprint(character) && !isspace(character) &&
character != '@' && character != '`' &&
!(tolower(character) == 'j' && keycode != SDLK_j) &&
!(tolower(character) == 'm' && keycode != SDLK_m)) {
character_ = character;
ctrl_ = ctrl;
cmd_ = cmd;
Expand Down

0 comments on commit 929ec99

Please sign in to comment.