Godot Version
4.3 stable
Question
I have the following script on a ColorRect:
extends ColorRect
var last_gui_event: int = 0
func _process(_delta: float) -> void:
if Time.get_ticks_msec() - last_gui_event > 500:
color = Color.WHITE
assert(not has_focus())
func _gui_input(event: InputEvent) -> void:
last_gui_event = Time.get_ticks_msec()
prints(last_gui_event, event)
color = Color.RED
If I click inside the ColorRect and continue to hold down the mouse button, then no matter where I move the mouse the ColorRect will continue to receive gui_input events (it stays red). Even if the mouse is outside the Control, the Control will continue receiving gui_input events as long as the mouse button is pressed.
I do not believe this is related to Control focus, because the Control never has focus; the assertion in the script passes.
This is awkward to work around. The whole point of the gui_input signal is to limit events to those happening inside the Control.
Is this a bug?
I’ve also demonstrated this in a short 3 minute video: https://www.youtube.com/watch?v=yomJZSPa43A