godotengine / godotengine/godot

Changing Control mouse_default_cursor_shape in gui_input prevents further mouse events

Open
#116,253 0 comments 0 reactions 0 assignees View on GitHub
bug topic:gui topic:input
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

v4.5.1.stable.official [f62fdbde1]
v4.6.stable.official [89cea1439]

### System information

Godot v4.6.stable - Windows 11 (build 26200) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 32.0.15.9174) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 threads) - 15.83 GiB memory

### Issue description

If mouse cursor shape is changed during input handling, further callbacks for this event are not triggered.

My use case is to connect to `gui_input` for all clickable Controls to change mouse cursor on click, independent from "regular" event handling.

The workaround is to change the cursor with `set_deferred`:
`button.set_deferred("mouse_default_cursor_shape", CURSOR_POINTING_HAND)`
Then, `_on_button_pressed` is properly invoked.

Looks like changing the cursor cancels the event. If this is known limitation, it should be added as a note in the [Control.mouse_default_cursor_shape documentation](https://docs.godotengine.org/en/stable/classes/class_control.html#class-control-property-mouse-default-cursor-shape). If so and it won't be fixed, I can make a PR to docs,

Somewhat similar to #93131

### Steps to reproduce

Have a Button with `gui_input` and `pressed` events:

```gdscript
func _on_button_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.is_pressed():
button.mouse_default_cursor_shape = CURSOR_POINTING_HAND
if event is InputEventMouseButton and event.is_released():
button.mouse_default_cursor_shape = CURSOR_ARROW

func _on_button_pressed() -> void:
print("pressed") # NEVER CALLED
```

When changing the cursor with `set_deferred`, the `_on_button_pressed` is properly invoked.

### Minimal reproduction project (MRP)

[cursor-change-issue.zip](https://github.com/user-attachments/files/25294512/cursor-change-issue.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.