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 https://www.unrealengine.com/en-US/tech-blog/creating-a-data-driven-ui-with-umg 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.
answered Jan 24 '19 at 08:46 PM
To share the content between two widgets, you can use Game Instance Blueprint. Create your own game Instance, set up variables and share.
answered Feb 07 '19 at 08:11 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here