dynamic buttons

how i create this code in ue4 :slight_smile: OnButtonClicked():
Set CurrentButtonClicked = ClickedButtonNumber

IF CurrentButtonClicked == 0:
    DefaultAction()  // Perform default action for the first button (Button 1 logic)

ELSE:
    HidePreviousData()  // Hide previous data from the scroll box

    IF CurrentButtonClicked == 1:
        AddChildWidgetForButton2()  // Add specific data for Button 2

    ELSE IF CurrentButtonClicked == 2:
        AddChildWidgetForButton3()  // Add specific data for Button 3

    // Add more conditions for additional buttons as needed

    ELSE:
        // Handle other button clicks or default action

What do you mean by “dynamic buttons”?
One thing you could do is create a Blueprint Class > ( All Classes ) Button ( not Widget Blueprint ), in this custom Button class you create an ID variable and a Get ID function to return the ID.
You add this custom Button to your Widget, when On Clicked event is fired you call Get ID so you can follow your script.

You can expose the ID variable if you set Instance Editable to checked and Expose on Spawn if you need to create Buttons.