From 55e5fa427afd8dc3947b39715110d56cdb2f8413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=27dreamsComeTrue=27=20Jasi=C5=84ski?= Date: Thu, 26 Mar 2020 21:35:12 +0100 Subject: [PATCH] Request immediate refresh of cursor in 2D editor while using shortcuts Fixes: #37333 --- editor/plugins/canvas_item_editor_plugin.cpp | 20 +++++++++++++++----- editor/plugins/canvas_item_editor_plugin.h | 1 + 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 4cc0bd47802..4f9395d5fe6 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2528,6 +2528,15 @@ void CanvasItemEditor::_gui_input_viewport(const Ref &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: @@ -2580,11 +2589,6 @@ void CanvasItemEditor::_gui_input_viewport(const Ref &p_event) { c = CURSOR_HSIZE; 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) { @@ -4380,7 +4384,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 f109b06aa32..d05ebe71eba 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -501,6 +501,7 @@ private: bool _gui_input_hover(const Ref &p_event); void _gui_input_viewport(const Ref &p_event); + void _update_cursor(); void _selection_changed();