Communicate between two widgets

I have two widgets. I want to send a value on from Widget A to Widget B. I have tried using Event Dispatchers, creating Custom Events, and Casting too. Casting and Event Dispatchers fail with an error “Accessed none trying to read property” Then I tried creating a custom event with an input variable, but it does not give any output.

Note: I have created a function override “OnMouseButtonDown” to feed value to my custom event or the event dispatcher.

I am following this tutorial Creating a Data-Driven UI with UMG - Unreal Engine to create a widget that contains information from a data table. I want to get information displayed in my main widget when I click an item. Please open the link so that you can have an idea of what I am trying to do if I am not able to explain well.

My problem is that I can’t send a variable value from one widget to another by using custom events, event dispatchers or casting. Maybe I am not setting up the targets properly or I am missing something very silly.

There’s a valuable piece of information which I don’t believe you’ve taken from the example provided, the fundamental portion of how the widgets are created.

You have a master widget (shop) that populates the contents (items) based off of data (data table).

The concept is simple. You create a widget that will create widgets. So your shop widget is the thing you are adding to the viewport. When it gets constructed, you trigger the creation of widgets for the shop items. That means, your master widget (shop) has access to the individual widgets one at a time (items) as they are being created and can pass forward information to them via variables which are set to “expose on spawn”.

Whenever you have variables set to be “exposed on spawn”, you can set them whenever your object gets created in code. For your purposes, you would be passing forward the information of price / picture / etc via the creation of an item widget.

To share the content between two widgets, you can use Game Instance Blueprint. Create your own game Instance, set up variables and share.

Thanks a million, It worked!!!

You can use BlueprintInterfaces

You can find various tutorials on YouTube about Interfaces as well.

Please accept in answers section.

Done as you requested

Hiya, sorry for digging up this old thread, but I’ve been stuck on this for a couple hours now, every tut online I found have you use an actor… My game is fully UMG base (mobile causal) and I’ve been going in circles… any help/guidance would be appreciated!

thx

Start a new thread and explain where, how and when you create the 2 widgets that need to talk to one another. Include as much detail as you can - what is the purpose of the comms, what is the scenario, who talks to whom…

1 Like