I have a widget which is essentially a button with particular styling and common functionality. I then have a UMG widget which contains a few of these buttons.
What I’m wondering is how to set the onClick events of these buttons? The onClick for each button fires a totally different function which is contained in the main UMG widget, so there’s no common functionality which could be put in the button blueprint itself.
One thing I have tried, which does work but seems a bit inelegant, is having each button with a string variable (eg. ‘PLAY’), which can be set in the containing widget upon spawn, and an onClick which sends this string to the main widget as an argument for a function called ‘UI_button_pressed’ which is essentially a switch on string leading to all the specific functionality for each button.
But is there any way to setup the onClick event from within the UMG widget that contains these buttons?