Merge pull request #28726 from megalike/add_mac_os_hotkeys_le

Support Mac OS hotkeys in line_edit
This commit is contained in:
Rémi Verschelde 2019-05-28 10:37:04 +02:00 committed by GitHub
commit 06da7bf6b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -160,6 +160,38 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
if (!k->is_pressed())
return;
#ifdef APPLE_STYLE_KEYS
if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) {
uint32_t remap_key = KEY_UNKNOWN;
switch (k->get_scancode()) {
case KEY_F: {
remap_key = KEY_RIGHT;
} break;
case KEY_B: {
remap_key = KEY_LEFT;
} break;
case KEY_P: {
remap_key = KEY_UP;
} break;
case KEY_N: {
remap_key = KEY_DOWN;
} break;
case KEY_D: {
remap_key = KEY_DELETE;
} break;
case KEY_H: {
remap_key = KEY_BACKSPACE;
} break;
}
if (remap_key != KEY_UNKNOWN) {
k->set_scancode(remap_key);
k->set_control(false);
}
}
#endif
unsigned int code = k->get_scancode();
if (k->get_command()) {