Get position in Widget

I have a problem on trying to get the position i have in the Widget. What im trying to do is to get the border’s position on the widget, how can i do it?

Hey T -

If your Border is a direct child of a Canvas Panel, then you can get positional data on it by the following steps:

  • Set the Border’s “IsVariable” checkbox to true so you can place it on a graph
  • Use the “Slot as Canvas Slot” to find this border as a specific child of the canvas panel (where the position comes from)
  • Then call “GetPosition” to get the (x,y) coordinates of that slot (which has your border in it)

I don’t exactly remember … but the origin point of (0,0) might be located in the center of the screen and that might depend on the anchor points you’re using … So the top left might be like -0.5 x screen width and -0.5 x screen height perhaps, so you might need to do some math on the position once you get it to convert to screen space.

2 Likes

Yeah, just checked. The position you get is relative to where the anchor point for the border is placed. So with the anchor placed in the center, this white border is up -300 and right +100 from there. If you anchor from the bottom left corner, then all values will be positive from that point up and to the right. Just dont use the anchor where it does from all 4 corners because then you’ll have to deal with top, bottom, left and right values all staying in sync in order for the size of the border to remain the same.

Hi! Sorry for being late. Did you finally find out how to do it? I mean, I got this widget with some buttons and I’m creating an “OnDrop” event over. And to check over which button I leave the dragged widget, I need to know the location of the buttons (the surface they occupy). Thanks!

1 Like

Were you been able to achieve that?