Enable Widget from different widget

Hey guys,

So I’ve created a ‘main_menu’ widget with a button called ‘Quit’ and a ‘confirm_quit’ widget with a yes and no button.
Concerning the ‘main_menu’, when pressed on ‘Quit’, the following happens:
OnClicked → Set is enabled = false → Create Widget → Add to viewport.
So far so good, I can see the widget and when clicked on ‘Quit’ it calls the ‘confirm_quit’ widget.

Now, when pressed on the ‘no’ button, I want ‘main_menu’ to be enabled again…
How can I access the ‘main_menu’ widget from my ‘confirm_quit’ widget to set it enabled again?

I did take a look at: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/BlueprintComms/index.html but it did not seem to work.

There are several ways you can go about this.

The quickest one that pops to mind is to create an “Owner” variable inside of your “popup” of UserWidget type. That way when your widget constructs the popup, you assign the “Owner” to self. Inside your popup, when you choose no, call Owner->main_menu->set enabled.

Hope it helps :slight_smile:

Hey Justin, thanks for your answer. However I did not get it to work yet, I’m probably not doing what you’ve told me but I don’t know what I’m doing wrong. Here’s what I’ve got, this blueprint is the ‘yes’ and ‘no’ button. I’ve done what you said (i hope) on the ‘no’ button… http://oi60.tinypic.com/dq3sw5.jpg

I use event dispatchers for this, to avoid circular references. Build an event dispatcher in the popup, and call it something like “QuitDismissed”.

In the parent, when you make the popup, assign the event QuitDismissed to it, and use that to re-enable the parent.

Not quite, you should set the owner when you’re creating the popup, not inside the popup, inside the popup is where you should be using the owner.

However, Stuckbug’s suggestion is much easier to implement (I didn’t even think about it to be honest!).

In your Popup widget add an “Event Dispatcher” and give it an appropriate name (I called mine Toggle). Then drag the event dispatcher onto the Event Graph and choose Call, you will get a node that looks like my “call Toggle” and in your OnClicked (btn_ignore_quit) you will hook it up to it (removing what you curently have there)

Then in your menu widget, you would override the popup creation like this (you would be adding it to the viewport, I’m adding it to a horizontal box that I have set up for testing). Before you add it to viewport, you would assign the toggle event. That way, whenever you click cancel button, it will trigger that event.

Hope this helps :slight_smile:

From your “Create widget node”, click on “return value” and drag out a node, type “Assign” and you should get your Event Dispatcher name in there.

Almost got it, but somehow I can’t seem to get the node you got called ‘Bind event to Toggle’

And a minute later I got it! Thank you so much, I got it working :smiley: