I have a program which uses a TextureRect
for a mouse cursor, and a home-rolled focus system. It works fine, but in _ready
I set the global_position
of the mouse to the focused control, and a problem manifests.
When it's called in _ready
, it jumps to (0, -610); but if I await a timer set to 0.025 seconds, and then assign it, it (correctly) jumps to (0, 560). Checking the position of the control I'm jumping the cursor over shows that these are the global_position
values of the control at the respective times.
I would think I could just call_deferred
on the function that moves the mouse, and it would resolve it; but I still get the incorrect (0, -610) coordinate even then.
What is giving me this strange behavior? My current solution feels very much like a hack and I would like to do something else, or await
a signal, which would do it more cleanly. It's a bit of an eyesore, and I do not know what it is that I am waiting on. At what point is it safe to set the global_position
of one control to another?
I am running in Full Screen Exclusive Mode (but wish to support windowed as well), and my control is in a CanvasLayer
. The root control is maximized vertically and horizontally, and is a base control under the CanvasLayer
.