There’s a lot of things going on in your second post, it’s difficult to pin down just what you need help with. In your third post, the link you posted is pretty straight forward and fundamental - if you understand event dispatchers. What is happening is a ButtonWidget has a button in it, and that’s all it has, probably along with some identification data. The Onclicked event of the button executes an event dispatcher. The widget that created the ButtonWidget listens - has an event bound - to this dispatcher. You can actually bind to the button, you just need the button reference but I don’t see why you would do that because you can’t identify which button was clicked. The ButtonWidget can give such information.
My first thought is if you really need to create the building buttons at runtime? If you want a building menu like say Starcraft, then all the buttons could be created in the widget and set to be hidden, and then set to visible when appropriate.
I’ve been working a little bit on a project to see if I can figure it out myself, but it’s really just building on the link in your third post.
Basically I have a MainWidget containing the categories and buildings. When Creating the category widgets, they are given a unique ID. The Category widget has an event dispatcher that includes its ID that the Mainwidget listens for.
Then using a widget switcher the correct BuildingWidgets are shown. Widget switcher: https://www.youtube.com/watch?v=7Mbe-hQl0Yg
So if the Category with the ID of 1 is clicked, the MainWidget hears that and updated the widget switcher so that the buildings of category 1 are shown.
The MainWidget also creates and listens to the BuildingButtons in the same manner.
The MainWidget is informed that a BuildingButton has been clicked and is provided with the ID, say building type. It then triggers an event dispatcher of its own, which I guess the player controller listens to and passes the ID. The Player controller can then use this ID to say spawn an actor or whatever.
I can share the project, it’s only 19MB. I used the PuzzleExample and the relevant blueprints are: PuzzlePlayerCharacter, MainWidget, BuildingWidget, Categorywidget. Most of it happens in the MainWidget.
Note that I am using some enums and hard coded TMaps to act as my ‘data base’.