Merge pull request #12489 from groud/fix_moving_control_with_direction_key
Fixes keybord directionnal keys not moving nodes in the 2D editor
This commit is contained in:
commit
80427c1aa2
1 changed files with 26 additions and 26 deletions
|
@ -1205,6 +1205,32 @@ void CanvasItemEditor::_gui_input_viewport_base(const Ref<InputEvent> &p_event)
|
|||
if (!viewport_base->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field()))
|
||||
viewport_base->call_deferred("grab_focus");
|
||||
}
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid()) {
|
||||
if (k->is_pressed() && drag == DRAG_NONE) {
|
||||
// Move the object with the arrow keys
|
||||
KeyMoveMODE move_mode = MOVE_VIEW_BASE;
|
||||
if (k->get_alt()) move_mode = MOVE_LOCAL_BASE;
|
||||
if (k->get_control() || k->get_metakey()) move_mode = MOVE_LOCAL_WITH_ROT;
|
||||
|
||||
if (k->get_scancode() == KEY_UP)
|
||||
_key_move(Vector2(0, -1), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_DOWN)
|
||||
_key_move(Vector2(0, 1), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_LEFT)
|
||||
_key_move(Vector2(-1, 0), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_RIGHT)
|
||||
_key_move(Vector2(1, 0), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_ESCAPE) {
|
||||
editor_selection->clear();
|
||||
viewport->update();
|
||||
} else
|
||||
return;
|
||||
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
|
||||
|
@ -2001,32 +2027,6 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
if (k.is_valid()) {
|
||||
if (k->is_pressed() && drag == DRAG_NONE) {
|
||||
// Move the object with the arrow keys
|
||||
KeyMoveMODE move_mode = MOVE_VIEW_BASE;
|
||||
if (k->get_alt()) move_mode = MOVE_LOCAL_BASE;
|
||||
if (k->get_control() || k->get_metakey()) move_mode = MOVE_LOCAL_WITH_ROT;
|
||||
|
||||
if (k->get_scancode() == KEY_UP)
|
||||
_key_move(Vector2(0, -1), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_DOWN)
|
||||
_key_move(Vector2(0, 1), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_LEFT)
|
||||
_key_move(Vector2(-1, 0), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_RIGHT)
|
||||
_key_move(Vector2(1, 0), k->get_shift(), move_mode);
|
||||
else if (k->get_scancode() == KEY_ESCAPE) {
|
||||
editor_selection->clear();
|
||||
viewport->update();
|
||||
} else
|
||||
return;
|
||||
|
||||
accept_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) {
|
||||
|
|
Loading…
Reference in a new issue