Widget buttons opening another widget?

Lets say I have a widget called Widget 1. With Widget 1, you have the option to choose from two buttons, Button 1 and Button 2. Both buttons load to another widget called Widget 2

Now, is it possible? I want to load from Widget 1 to Widget 2, and when clicking on Button 1, you would see something different when loading to Widget 2 when compared to clicking on Button 2 to Widget 2.

I can find a solution if all button functionalities from both widgets were combined as one widget. But I already have Widget 2 set up and want to find a way with this approach.

Any help would be appreciated.

Firt, Way do you not use a WidgetSwitcher?

Second, When you press Button 1, what do you want, do you want load a different widget, or teleport to a room etc…?

Yes, absolutely it’s possible! I just figured this out on my own yesterday and here’s how you do it.

I assume you have something like a menu with buttons on it and one of those buttons will open another hud widget. Well, the complexity differs depending on what you are trying to accomplish but here’s the basis for it.

On your Widget 1 select the On Press bind event. This can be whatever best suits your needs so you may prefer on release for example.

Inside this you will need to create a new variable and name it PlayerControllerRef Set the type of variable to your player controller. Set it to Expose on Spawn and Instance editable. Compile

Drag the player controller ref variable into the blueprint as GET.

Drag off of that player controller variable and type create widget. Do that, create widget. Make sure context sensitive is checked to avoid looking for it.

In this new widget dialog, select the widget you want to come up next. So Widget 2.
Drag over player controller ref into the player controller ref slot (assuming you have one).
You can pass other things here assuming widget 2 has exposed references. This is important to know because you may want to pass over variables etc…

In the return value, drag it off and promote to variable. Name it whatever you want, it’s a reference for your Widget 2. Make sure that the variable type is the widget 2 reference.

Connect the nodes together and then after setting the new reference variable, drag off the white node thing and search for “add to viewport”. Connect the widget 2 reference variable that was just set to the target of the viewport node.

Drag off from the viewport and search for set visibility.

From here drag your widget 2 reference variable as GET and connect it to the visibility target. Make sure you select Visible in the dropdown.

Optional: If you want to keep passing the player controller or whatever else, set the reference inside widget 2 (Just like you did earlier when you created the player controller reference variable) and go back to widget 1 to pass it along in the create [widget 2] widget.

I hope this makes sense!

1 Like

I want to go from one widget to another. Both UI buttons would load me to whole different widget. Both of these buttons load to same widget, but how can I make certain ui panels appear depending on which button that I clicked from the previous widget? I know Widget Switcher can do that for 1 widget. but can it do it for my approach? Thank you for your reply.

Thank you very much for sharing ! I’m going to give this a try and I will let know you how it goes. Thanks for your help :slight_smile:

OK, so I’m on widget 1 and was wondering if you meant to create bind event by clicking on blueprint button 1 and then, on the Widget Designer Editor display and when I scroll down, I see different possible events on the “Events” tab, but I don’t see a On Press bind event, just a On Pressed Event.

So I clicked on “On Pressed Event” instead, created a new variable, named it and set it to Expose on Spawn and Instance Editable. My other question is what type of Player Controller variable reference is it? Thank you.

This is way late to the party but why can’t you just use “remove all widgets” and then “create widget” directly after in the BP sequence to create the new widget/s?