extends Control class_name ModalPopup var control : Control onready var title := get_node("title") as Label onready var background := get_node("background") as Panel func _init(): anchor_right = 1.0 anchor_bottom = 1.0 func _ready(): get_node("back").connect("pressed", self, "hide") func popup_control(title: String, item: Control): self.title.text = title control = item control.connect("visibility_changed", self, "closed") control.anchor_left = background.anchor_left control.anchor_top = background.anchor_top control.anchor_right = background.anchor_right control.anchor_bottom = background.anchor_bottom control.margin_left = 20 control.margin_top = 20 control.margin_right = -20 control.margin_bottom = -20 add_child(control) show() control.show() # self.visible = true func closed(): if control.visible == true: return control.disconnect("visibility_changed", self, "closed") remove_child(control) self.hide()