Hello, I’m working on a menu, and I have 2 sub-menu’s in that menu. There is an int inside the first one called “targetIndex”, but I would like the second sub menu to be able to set it when a button is clicked. I can’t find a way to access a variable outside of the subMenu a button is in though - I would love any advice on the topic, thank you for your time!
Here’s a video demonstration of my problem:
You’ll need to make an Event Dispatcher in your submenu widget, then call it when you click a button. Then in the other (parent) menu, bind that dispatcher to an event/function.
For example, I have an Event Dispatcher called Clicked on a Custom Button Widget. It has an Input of type Integer called ID (To identify a specific button, when there are multiple in a list or something).
I then call the Dispatcher when the button gets clicked
Now in another widget, I can add this custom button widget and then bind the Clicked Dispatcher like a regular button.
So, in your case I would create a single Dispatcher with an Integer Input for targetindex. Call that dispatcher on each button’s clicked event with the appropriate targetindex. Then in the first widget, you can use this dispatchers event to set targetindex.
Thank you so much for the explanation - I’ve been trying to follow a long but I get a bit lost around the middle of your description. Here’s what I got so far, is this sort of along the right track? Or am I doing it completely wrong?
Thanks again for your help!
Index would be the value that you want iPoseIndex to be set to.
OK, wait so hold on - Now that I have this event dispatcher, I’m still not sure how to apply it. Let’s say when the button is clicked I want it to set the index variable in the main menu to 6. How do I do it from where I am now?
Now when you select the submenu widget in main menu, on the details panel at the bottom, there should be an event called SetIndex (like clicked, pressed etc… for buttons). Click + on that SetIndex Event to add it to the graph. This SetIndex event will get called when you call the SetIndex dispatcher on the submenu. Then you can use this event to set iPoseIndex
OK, I think I ALMOST got it, I just got lost at the last step - Here’s what I’ve got so far!
I’m just not sure how to call the SetIndex dispatcher on the submenu and have it set the iPoseIndex
You called it in your previous reply
OMG IT WORKED!!!
Thank you so much for your help, my question has been answered, you are awesome!!!
Hope you have a Fantastic Day!!!