How to get the viewport position of an UMG element?

Hi,

question is above. How can i get the x/y of any umg elements like images or whatever. Not
regarding of any parents or other childrens, but just x/y in viewport/screen.

Thanks in advance.

I was wondering this same thing.

I see that there is function called SetPositionInViewport, which doesn’t seem to change positions of widgets. It makes me think GetPositionInViewport should exist but it seemingly does not

Try this

		UCanvasPanelSlot* canvasSlot = UWidgetLayoutLibrary::SlotAsCanvasSlot(yourWidget);
		canvasSlot->GetPosition();

Ok, sounds like the solution :smiley: Great :smiley:

But i want to make everthing with blueprints.

The reason for that is that it is not user-friendly when the user has to use an additional plugin (I do development within my own plugin :D)
Is there an existing BP solution. If not, i will add your solution as a function)

Meanwhile i have found a solution, but it worked for my case adventitiously. It is not a solution for everybody:

Solution:

  1. Create a “Border” cause it supports MouseOnMove

  2. Create and bind MouseOnMove to a function

  3. Within the function you have a “MyGeomtry” output

  4. Connect the “Absolute to Local” node and multiply it with the DPI Scale
    To get the right DPI Scale Value, do this:

  5. Create an external curve for DPI Scale

  6. Cast to that curve and read out the “time value” depending on Y Value
    By default the Y Value is the vertical resolution:

  7. So create a “Get Viewport Size” and plug in the Y Value to the “read out” of
    the curve

This solution only gives you the right Values when hovering the border with the mouse.