Updating Widget Location in Viewport (And why I have to do it this specific way)

Today I decided to tackle something new to me: Dynamically moving a button around in a widget so I can have it appear in different places doing different things (without having to create a bunch of different buttons and hiding and unhiding them), and I ran into something that is making me scratch my head.

My button is its own widget within another widget. There’s no canvas panel in the button widget, it’s just a button.

I set it to is variable and go into the graph and try this

Obviously originally I had it coming off the event construct node, here I just have it as an example. Anyway it didn’t work, it did nothing. So I googled the problem and eventually found out the way to do it is like this…

.
Which did work, and worked splendidly. The problem is I have no idea why. I get now that the slot contains the position data, that’s all fine and data but this leaves me with two questions:

  1. What does set position in viewport do then? It comes up if I drag off the get W Event Icon widget reference variable with context sensitive selected. It even has a nice nifty position variable.
  2. Why do I have to cast to the canvaspanelslot? Everyday I feel like I understand casting and everyday I run into something that makes it more confusing. If I have the specific reference to the specific widget I want to update, why would I need to cast instead of just set the position directly from the widget reference?

And finally is there a video series/tutorial/documentation/video whatever that I can watch that will help me better understand this stuff? Especially casting in blueprints?

Thanks as always.

1 Like

I am affected by the same issue. I expected handle the position by “setPositionInViewport”
I found this post too: