How to handle clicking + click dragging

In Godot this is solved by checking the distance, that the mouse has traveled between the mouse-button pressed and mouse-button released events.

If the distance is smaller than 10 pixel, then Godot assumes a click.

If the move distance while mouse-button is pressed accumulates to 10 pixel or more, then dragging is started.

For details on how this is implemented in C++ in Godot, you can dig into the function Viewport::_gui_input_event.

2 Likes