Issue: Drag & Drop Lag with Mouse

Godot Version

4.4.1 on Windows 11

Question

Hey everyone,

Lately, I’ve been struggling to implement a smooth drag-and-drop mechanic using the mouse. Most of the solutions I’ve found and tried still have noticeable lag. After testing several approaches, the only one that effectively removes lag is by using a custom mouse cursor - and I’m okay with its limitations for my use case.
My logic flow:

  1. On left-click on a TextureRect node:
  • Hide the TextureRect
  • Set the mouse cursor to its texture
  1. While dragging
  • Continuously update the cursor position (still some lag, but acceptable as it is not visible)
  1. On second left-click (to drop):
  • Disable input
  • Show the TextureRect node
  • Wait briefly
  • Reset the cursor to default
  • Enable input

This setup mostly works well, but I’m still seeing a slight flicker of the texture when moving the mouse quickly right as the drop occurs. The code can be seen on pastebin. It can tested by creating a scene with a root of TextureRect node and adding the script to the node.

Question

Any ideas or suggestions on how to clean up the last bit of visual glitch? Or maybe propose another method of implementation?

Any help will be greatly appreciated!

I found a bug in my script. The improved version. It is working better but still there could be some texture flickering.