Center widget on viewport


Sorry for my bad english
I created a message box widget that I want to place anywhere I want.
The size of the message box is variable.

I want to position dynamically the the top left on corner of the widget on the viewport so I use the node Set Position In Viewport.
It’s seems working when the position is get from other widgets but in some cases I don’t have other widget and I want to center it.
So I get the viewport size0.5 and I want to remove my dynamic widget size0.5.
All the technics I try, give unexpected results:

Here 3 technics:

  • Canvas -> Get Desired Size always return 0
  • MessageBox -> Slot As Canvas -> Get Size return values but does’nt center the widget
  • MessageBox -> Get Desired Size always return 0

Another thing I don’t understand: Get Viewport Size is supposed to return size in pixels so why i need to check the RemoveDPIScale to have the top left and corner in the center (without substraction of the widget size)

You have those Anchors settings right there in details, use them for anything static.