How to add LineEdit object to Popup created in GDScript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tommila
:warning: Old Version Published before Godot 3 was released.


I’ve created a modal popup with nested LineEdits, the problem is that the popup closes when I try to select one of the LineEdits with a mouse. TAB-select works fine though. i’ve tried messing with set_focus_mode and set_stop_mouse but nothing seems to work. Here’s a example code.

extends Button

onready var m_popup =
onready var m_x =
onready var m_y =
func _ready():
    connect("pressed", self, "clicked")

    var hBox =


func clicked():
   var pos = get_global_mouse_pos()
   pos.x -= 125
   pos.y += 10
:bust_in_silhouette: Reply From: BE-Never Games

That is because a popup is supposed to close when you click somewhere outside of its boundaries and I am going to guess that the LineEdits are not within its margins due to the Container. There are a couple of solutions for this:
You could simply use a normal “Control” and use .show() and .hide() for manipulating its visibility. You can also use these methods on a popup by the way instead of .popup() which will show the Popup without disappearing automatically.
And finally, you can set the popup to “Exclusive” with the method set_exclusive(true) in order to make it hide other popups on the screen and to stay visible.

I hope any of these solutions help you! :smiley:

Manually resizing the popup boundaries/size solved this problem. It’s interesting, though, that the popup object isn’t inherited from a container object. Thanks for pointing me to the right direction!

tommila | 2017-07-27 08:00