All hail @Lordlolek, solver of ancient mysteries. Thank you!
The question is asking how to get the position, not set…
I faced this same issue when testing out a custom tooltip issue and this is the solution I came up with. It will work at any screen ratio and scale.
get the cached geometry of the widget you want to use as a reference to set location.
Use that location to set the location of your new widget. Here I use a canvas panel
to have anchor control.
perfect alignment with an offset exactly the size of the referenced widget.
Nothing is hardcoded, so the method can be used to update its location to anything.
I hope this helps solve the issue
This wizard with ancient knowledge of mathematics and widgetry, Inskribe, has aided me in my quest for a properly positioned on-hovered popup widget. Thank you, fine wizard. May your ancient knowledge and impressive mathematics continue to be passed down through generations
Here is what worked for me. I’m making a game with gamepad capability. I wanted a mini menu with options to appear while navigating my inventory depending on what button I currently had hovered and where that button was on my screen (because my game is split screen 2 player).
I created a separate widget with a canvas panel (you can also use an overlay instead), and a vertical box with my buttons in the box. Checking the Is variable box for the vertical box.
Even though I’m using a gamepad, the hover/focus simulates a mouse location. Therefore, I can use the “Get Mouse Position on Viewport” function to set the position of the canvas slot for the mini menu vertical box variable (drag off the vertical box variable to get slot as canvas slot). Using the mouse location in this manner will default the position to the center of the hovered button. You will have to make other adjustments if you want to offset the alignment. This solution was good enough for my game, so I stuck with it.
Hope this helps.