summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric M <itsjusteza@gmail.com>2020-09-17 11:46:04 +1000
committerEric M <itsjusteza@gmail.com>2020-11-23 21:52:15 +1000
commit7941235e06c8acf1cb2888de3db8905c60c8ff00 (patch)
treef8c8f6abf0f97844bbf612502d8cbe36c3bc1360
parentefe5c250d5c0f749ed594ddd04fa76ca20abe4a4 (diff)
Add is_valid() check for InputEventKey in CanvasItemEditor.
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp30
-rw-r--r--scene/gui/menu_button.cpp2
2 files changed, 17 insertions, 15 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index dbd61a3a96..2d85a3a570 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -479,22 +479,24 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
return;
}
- if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
- viewport->update();
- }
-
- if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
- if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
- // Multiply the grid size
- grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
+ if (k.is_valid()) {
+ if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) {
viewport->update();
- } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
- // Divide the grid size
- Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
- if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
- grid_step_multiplier--;
+ }
+
+ if (k->is_pressed() && !k->get_control() && !k->is_echo()) {
+ if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) {
+ // Multiply the grid size
+ grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
+ viewport->update();
+ } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) {
+ // Divide the grid size
+ Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
+ if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
+ grid_step_multiplier--;
+ }
+ viewport->update();
}
- viewport->update();
}
}
}
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index bccea315c4..b98b3f7094 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -123,7 +123,7 @@ MenuButton::MenuButton() {
set_toggle_mode(true);
set_disable_shortcuts(false);
set_process_unhandled_key_input(true);
- set_enabled_focus_mode(FOCUS_NONE);
+ set_focus_mode(FOCUS_NONE);
set_action_mode(ACTION_MODE_BUTTON_PRESS);
popup = memnew(PopupMenu);