I’m making a game that has a dialog box, and I made a big transparent color rect behind that you can click in order to close the dialog once it has finished, that works fine, however, the problem comes from the fact that if I have a button for example behind my mouse when I click on the color rect once to close it, it will close the dialog box but also trigger the button, as if It made a double click or the click passed through, maybe it has something to do with the input event handling order, however I searched for it and I don’t know how to change that, I should also say that the dialog box is a Control Node but the button is a node 2D with an area 2D because technically is part of the game and not GUI. I hope someone knows the reason for this, thank you!
So I have this text box that appears when the scene loads, once the text is fully displayed you can click anywere to close the window. I made the color rect on top slightly yellow so you can see it clearly.
You can click on the godot icon on the left to go to the second level 2.
The problem is that if you click directly on this godot icon, while the text box is still open it will carry you to the second level.
It works, I thought about doing something similar, using a timer to add some delay, but I thought maybe someone would come up with a more “elegant way” to do it, but I guess it is fine.
I changed the variable name of just_gone to stillvisible, to make it more clear for me.
I leave this here in case someone needs it
DialogBox script:
0.004 seems to be the minimum time for it to work
func _on_color_rect_gui_input(event):
if Input.is_action_just_pressed("BothClicks") and label.visible_ratio >= 1:
visible=false
clean_label()
stillvisible = true
await get_tree().create_timer(0.1).timeout #0.004
stillvisible = false
Movement script:
func _on_area_2d_input_event(viewport, event, shape_idx):
if Input.is_action_just_pressed("BothClicks"):
if DialogBox.stillvisible==true: return
GameManager.change_room(nextscene, "normal")
Tell me if this is the way you did it, and thank you for your help!