TextEdit/LineEdit: Handle numpad arrows if NumLock is disabled

This commit is contained in:
Ignacio Etcheverry 2016-01-07 21:38:38 +01:00
parent b6388e6001
commit a825cfd932
2 changed files with 59 additions and 16 deletions

View File

@ -245,12 +245,26 @@ void LineEdit::_input_event(InputEvent p_event) {
delete_char(); delete_char();
} }
} break; } break;
case KEY_KP_4: {
if (k.unicode != 0) {
handled = false;
break;
}
// numlock disabled. fallthrough to key_left
}
case KEY_LEFT: { case KEY_LEFT: {
shift_selection_check_pre(k.mod.shift); shift_selection_check_pre(k.mod.shift);
set_cursor_pos(get_cursor_pos()-1); set_cursor_pos(get_cursor_pos()-1);
shift_selection_check_post(k.mod.shift); shift_selection_check_post(k.mod.shift);
} break; } break;
case KEY_KP_6: {
if (k.unicode != 0) {
handled = false;
break;
}
// numlock disabled. fallthrough to key_right
}
case KEY_RIGHT: { case KEY_RIGHT: {
shift_selection_check_pre(k.mod.shift); shift_selection_check_pre(k.mod.shift);
@ -287,6 +301,13 @@ void LineEdit::_input_event(InputEvent p_event) {
default: { default: {
handled=false;
} break;
}
if (handled) {
accept_event();
} else {
if (k.unicode>=32 && k.scancode!=KEY_DELETE) { if (k.unicode>=32 && k.scancode!=KEY_DELETE) {
if (editable) { if (editable) {
@ -298,15 +319,9 @@ void LineEdit::_input_event(InputEvent p_event) {
} }
} else { } else {
handled=false;
}
} break;
}
if (handled)
accept_event();
else
return; return;
}
}
selection.old_shift=k.mod.shift; selection.old_shift=k.mod.shift;

View File

@ -1740,6 +1740,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} }
} break; } break;
case KEY_KP_4: {
if (k.unicode != 0) {
scancode_handled = false;
break;
}
// numlock disabled. fallthrough to key_left
}
case KEY_LEFT: { case KEY_LEFT: {
if (k.mod.shift) if (k.mod.shift)
@ -1786,6 +1793,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_post_shift_selection(); _post_shift_selection();
} break; } break;
case KEY_KP_6: {
if (k.unicode != 0) {
scancode_handled = false;
break;
}
// numlock disabled. fallthrough to key_right
}
case KEY_RIGHT: { case KEY_RIGHT: {
if (k.mod.shift) if (k.mod.shift)
@ -1829,6 +1843,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_post_shift_selection(); _post_shift_selection();
} break; } break;
case KEY_KP_8: {
if (k.unicode != 0) {
scancode_handled = false;
break;
}
// numlock disabled. fallthrough to key_up
}
case KEY_UP: { case KEY_UP: {
if (k.mod.shift) if (k.mod.shift)
@ -1849,6 +1870,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_cancel_code_hint(); _cancel_code_hint();
} break; } break;
case KEY_KP_2: {
if (k.unicode != 0) {
scancode_handled = false;
break;
}
// numlock disabled. fallthrough to key_down
}
case KEY_DOWN: { case KEY_DOWN: {
if (k.mod.shift) if (k.mod.shift)