summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd2
-rw-r--r--scene/gui/control.cpp5
-rw-r--r--scene/main/scene_tree.cpp1
-rw-r--r--scene/main/viewport.cpp4
-rw-r--r--scene/main/window.cpp12
-rw-r--r--scene/main/window.h2
6 files changed, 23 insertions, 3 deletions
diff --git a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd b/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
index d71f2592fe..cf6d68333d 100644
--- a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
+++ b/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
@@ -34,5 +34,5 @@ func _get_output_port_name(port: int) -> String:
func _get_output_port_type(port: int) -> int:
return PORT_TYPE_SCALAR
-func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
+func _get_code(input_vars: Array[String], output_vars: Array[String], mode: int, type: int) -> String:
return output_vars[0] + " = 0.0;"
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index d8659b1f18..2866a5ad6c 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2663,6 +2663,11 @@ void Control::set_default_cursor_shape(CursorShape p_shape) {
ERR_FAIL_INDEX(int(p_shape), CURSOR_MAX);
data.default_cursor = p_shape;
+
+ if (!is_inside_tree()) {
+ return;
+ }
+ get_viewport()->get_base_window()->update_mouse_cursor_shape();
}
Control::CursorShape Control::get_default_cursor_shape() const {
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index d1e8b477a6..0ff99bdab6 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -1087,6 +1087,7 @@ void SceneTree::_change_scene(Node *p_to) {
if (p_to) {
current_scene = p_to;
root->add_child(p_to);
+ root->update_mouse_cursor_shape();
}
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index de6aa2b139..0082e7b061 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1551,7 +1551,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_preview_id = ObjectID();
}
_propagate_viewport_notification(this, NOTIFICATION_DRAG_END);
- // Change mouse accordingly.
+ get_base_window()->update_mouse_cursor_shape();
}
_gui_cancel_tooltip();
@@ -1572,7 +1572,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.dragging = false;
gui.drag_mouse_over = nullptr;
_propagate_viewport_notification(this, NOTIFICATION_DRAG_END);
- // Change mouse accordingly.
+ get_base_window()->update_mouse_cursor_shape();
}
gui.mouse_focus_mask &= ~mouse_button_to_mask(mb->get_button_index()); // Remove from mask.
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 6837fcae21..a1124274d8 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -378,6 +378,18 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) {
}
}
+void Window::update_mouse_cursor_shape() {
+ // The default shape is set in Viewport::_gui_input_event. To instantly
+ // see the shape in the viewport we need to trigger a mouse motion event.
+ Ref<InputEventMouseMotion> mm;
+ Vector2 pos = get_mouse_position();
+ Transform2D xform = get_global_canvas_transform().affine_inverse();
+ mm.instantiate();
+ mm->set_position(pos);
+ mm->set_global_position(xform.xform(pos));
+ push_input(mm);
+}
+
void Window::show() {
set_visible(true);
}
diff --git a/scene/main/window.h b/scene/main/window.h
index 3d8e337b4a..27a02b837f 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -205,6 +205,8 @@ public:
void set_visible(bool p_visible);
bool is_visible() const;
+ void update_mouse_cursor_shape();
+
void show();
void hide();