Multiple WindowDialogs

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DrewS

I have a scene that is comprised of a root WindowDialog, that is opened using the popup_centered() function, with the popup_exclusive set true. This scene is then instanced a number of times. When each one is opened, multiple windows show up, but I can only interact with the last one opened. How can I make it so I can interact with all of them at the same time?

Honestly, why do you actually set popup_exclusive when you do NOT want to use the popup exclusively?

OK, ok. I now read the docs. But it seems not to be intended anyway. Exclusive should mean that this popup is receiving the attention… and nothing else… (that is why it doesn’t hide when you click elsewhere). It behaves like a modal dialogue.

Maybe just arrange the WindowDialogs without Popup so they can all be accessed? (Enumerate open controls an rearrange when more will open.)

Maybe a screenshot would help to understand what you exactly want to achieve.

wombatstampede | 2019-02-27 07:11

I do not have a screenshot at the moment, as I broke the system refactoring my code. But, I think I can explain it, well enough. I am trying to effectively do something similar to the Divinity Original Sins loot/container UI like so. Where you can open multiple containers and drag items to/from them and the player inventory and move the windows around. Which is why I chose to use a WindowDialog.

DrewS | 2019-02-27 22:23

:bust_in_silhouette: Reply From: fayolaa

This seems to be a difficult act, I have learned a lot about it but have not found a solution!

:bust_in_silhouette: Reply From: Zylann

If you want them both on screen a workaround would be to simply use Panel which you customize to look like a window and show up on front, because popups are “shortcuts” which are heavily made to be single on top of everything else.

:bust_in_silhouette: Reply From: DrewS

I solved this problem by creating a custom Panel to control this, like @Zylann suggested.

On the panel I added a script to drag the windows around.

extends Panel

var _reset_position = Vector2()
var _previous_mouse_position = Vector2()
var _is_dragging = false

signal on_open
signal on_closed

func _ready():
	_reset_position = rect_position

func _process(delta):
	if _is_dragging:
		var mouse_delta = _previous_mouse_position - get_local_mouse_position()
		rect_position -= mouse_delta

func _gui_input(event):
	if event.is_action_pressed("ui_select"):
		_is_dragging = true
		_previous_mouse_position = get_local_mouse_position()
	if event.is_action_released("ui_select"):
		_is_dragging = false

func show():
	emit_signal("on_open")
	rect_position = _reset_position
	visible = true

func hide():
	emit_signal("on_closed")
	visible = false

func _on_TextureButton_pressed():
	hide()