summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-23 09:49:48 +0200
committerGitHub <noreply@github.com>2020-07-23 09:49:48 +0200
commit5671469724c4367272a7d7d3bda0b92b3b43709d (patch)
tree2323192b12391b739913bb15e9dc776ca9cbf87d /editor/plugins
parent6ad0aecb3b6757ea26f10f39ecc12cb53ff928f8 (diff)
parent55e5fa427afd8dc3947b39715110d56cdb2f8413 (diff)
Merge pull request #37336 from dreamsComeTrue/canvas-editor-change-cursor
Request immediate refresh of cursor in 2D editor while using shortcuts
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp20
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h1
2 files changed, 16 insertions, 5 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 3c6556a310..f3508cedbd 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2589,6 +2589,15 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
_gui_input_hover(p_event);
// Change the cursor
+ _update_cursor();
+
+ // Grab focus
+ if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) {
+ viewport->call_deferred("grab_focus");
+ }
+}
+
+void CanvasItemEditor::_update_cursor() {
CursorShape c = CURSOR_ARROW;
switch (drag_type) {
case DRAG_NONE:
@@ -2642,11 +2651,6 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
}
viewport->set_default_cursor_shape(c);
-
- // Grab focus
- if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) {
- viewport->call_deferred("grab_focus");
- }
}
void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) {
@@ -4464,7 +4468,13 @@ void CanvasItemEditor::_button_tool_select(int p_index) {
}
tool = (Tool)p_index;
+
viewport->update();
+ _update_cursor();
+
+ // Request immediate refresh of cursor when using hot-keys to switch between tools
+ DisplayServer::CursorShape ds_cursor_shape = (DisplayServer::CursorShape)viewport->get_default_cursor_shape();
+ DisplayServer::get_singleton()->cursor_set_shape(ds_cursor_shape);
}
void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) {
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 12abf05cf9..ea58fb1e36 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -492,6 +492,7 @@ private:
bool _gui_input_hover(const Ref<InputEvent> &p_event);
void _gui_input_viewport(const Ref<InputEvent> &p_event);
+ void _update_cursor();
void _selection_changed();