How to get button widget UMG

Is there a way to get parent user widget from button? For example - I created MyWidget in UMG and in blueprint have a reference to button added to MyWidget. Now I want to get MyWidget from that button. Is it possible in UE4?

You can do this a couple different ways.

  1. You can use the node “GetParent”

  2. You can create a function in you Button widget that you return a stored reference to its Parent Widget

Hope that helps =)

You didn’t get me right. I know about GetParent, but it will only give parent widget component (Grid slot, canvas slot).

I did something like that:

Created new UMG Widget Blueprint called MyWidget.

Added default button to it, a grid panel etc.

Then I’ve got reference to this button somewhere in blueprints.

And now I want to get MyWidget from this button in order to be able to get functions, variables, etc that were created in MyWidget Blueprint.

Second option gave me idea as nice workaround if i would create MyCustomButton and add it to MyWidget so if there is nothing that does what i want already i’ll propably do it like that.

Why you don’t reference the WG itself , why specially the button?

It’s complicated. I’m building my custom control system over buttons in UMG, because I need to switch focus beetween buttons that are created dynamically at different positions. I had some problems in positioning them from world to widget position, so they are now isolated widgets. But each of them contains few buttons. And I need switching beetween them too. Thanks to it I ended up with reference to button.

But using Devero second idea, i changed buttons to custom widgets that holds reference to parent and now its working.

Thanks for help guys :wink:

Thank was looking for this