Let me back up & describe my hierarchy for a moment. The prior example are from my options screen, which doesn’t pass through “enter/gamepad A” events, since the screen just has a “confirm/decline” button that sets everything. I’m attaching a new image from our inventory screen, which is structured thus:
- > MasterJournal (handles all input, uses a widget switcher to change panels)
— > InventoryPanel (houses the inventory scroll box, a list of all inventory items - my screenshot is from this widget)
------ > Inventory Item (a unique UMG widget for each item. Basically a button with a couple images)
— > CraftingPanel
— > EquipmentPanel
When the MasterJournal fires the Key Down Event, the children (in this case, InventoryPanel) have the the blueprint interface implemented, so they can receive the event (in this case, Key Down Event, which is in BPI_UI_Interface).
The buttons themselves just have a Custom Event (Simulate Click) which I fire by casting to the button class (UIW_InventoryItem). Basically I’m always sending a waterfall of events through the MasterJournal, and directing the events based on which is focused.
Incidentally, since you have an index, you don’t need to bother with the array of widgets. If you just use “Get Child At” on the widget that houses your buttons, it give you whatever widget is there. If you cast to that and it’s the wrong type, the cast fails and nothing bad happens. Same with a blueprint interface. If you try to fire an event on a widget and it doesn’t have the interface implemented, or the associated event, nothing bad happens.
Based on your images, I would suggest (mostly for reasons of extensibility & good housekeeping) that rather than adding a bunch of buttons to your screen, that you make a bunch of widget types that you can just embed.
In the case of my options screen, there are a bunch of generalized widgets I’m using.
UIW_OptionsScreen is the base screen, has the scroll box, and has a bunch of the other widgets added as “user widgets”.
UIW_Options_List, UIW_Options_Button, UIW_Options_Toggle, and UIW_Options_ toggle are all just a single widget designed to perform one of those actions. So If I want to add more toggles (Extreme Gore!, Big Head Mode!) I don’t need to change any base data, I just need to add another widget, give it the name, and bind it to whatever I want it to set.