How to center dialog_text of a AcceptDialog

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

I was following this tutorial on Youtube https://www.youtube.com/watch?v=PTt9v452BVw

and at some point he used an ‘AcceptDialog’. However, I’ve noted it starts with the text aligned left. I’m still quite new to the engine, so I tried adding a theme and fiddling with some options, but I got lost and this frustrated me a lot.

It’s something SO simple, and yet I can’t find a simple way to do it…

:bust_in_silhouette: Reply From: Friends-Games

You can’t, I’ve checked the documentation and it can’t be centered.

Yeah, I saw it as well, but just needed some confirmation. Thank you!

Gustavo Loureiro dos | 2020-07-16 17:01

:bust_in_silhouette: Reply From: njamster

You can from code:

extends AcceptDialog

func _ready():
	get_child(1).align = HALIGN_CENTER

The child-id might change though if you add children to the AcceptDialog yourself.

:bust_in_silhouette: Reply From: mustafamax

You can remove

AcceptDialog.visible = true

and add

AcceptDialog.popup_centered()

In Godot 4.x:

	%ConfirmationDialog.dialog_text = "Confirmations needed!"
	%ConfirmationDialog.get_child(1, true).horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER 
	%ConfirmationDialog.popup()