godot icon indicating copy to clipboard operation
godot copied to clipboard

Add option to force `_can_drop_data()` call

Open CrayolaEater opened this issue 1 year ago • 2 comments
trafficstars

Before

Cursor drag-drop state updates only if the mouse is moving

https://github.com/godotengine/godot/assets/38570835/410887d4-9097-43be-8345-406ced028c79

After

I fixed this by adding a new method force_can_drop_data_check() that will force the check to re-update the cursor state. In this example I made a new script and called get_viewport().force_can_drop_data_check() whenever the state of the panel changes. This is useful if you have custom logic dependent on whether the element can be dropped or not. This previously ran only if you are moving the mouse now you can force the check and keep the mouse still. NOTE: As you can see the cursor is not moving at all.

https://github.com/godotengine/godot/assets/38570835/a0675575-d25b-458c-8d26-38bf276ee852

CrayolaEater avatar Apr 20 '24 03:04 CrayolaEater

I think at least this should be done by Godot instead of asking users to call this method after dropping.

timothyqiu avatar Apr 20 '24 07:04 timothyqiu

I think at least this should be done by Godot instead of asking users to call this method after dropping.

This is not called after dropping, this just makes the can_drop_data to be called again with the last drag information

CrayolaEater avatar Apr 20 '24 11:04 CrayolaEater

Actually you can just use get_viewport().update_mouse_cursor_state() to update the mouse cursor.

kitbdev avatar Oct 14 '24 18:10 kitbdev

Closing because there is already a function that does all the required operations

CrayolaEater avatar Oct 14 '24 20:10 CrayolaEater