How to get instigator for a UI Button?

I’m trying to find a way to see who presses a button on the UI and grant them weapons based on that but I don’t know how to find the instigator for the button:

    OG_Button.OnClick().Subscribe(OG_Pressed)

    OG_Pressed(Message:widget_message):void =
        # [Code to find instigator here]
        OG_Granter.GrantItem(Instigator)
        if (PlayerUI:player_ui = GetPlayerUI[Message.Player], MyUI: overlay = MyMap[Message.Player]?, SelectedButton: text_button_base = text_button_base[Message.Source]):
            PlayerUI.RemoveWidget(MyUI)
           if (MyMap[Message.Player] = false) {}
        return

Any suggestions would be appreciated!

OG_Button.OnClick().Subscribe(OG_Pressed)

Does the .Subscribe not send you the agent ?
do you have an error on that line?

When you subscribe to a button press like

Button.OnClick().Subscribe(SomeFunction)

That should pass a widget_message

So you can subscribe to a function that takes a widget message and then define the player who clicked it like this.

SomeFunction(Message:widget_message):void=
    Player := Message.Player 
    DoSomething(Player)

DoSomething(Player:player):void=
    ItemGranter.GrantItem(Player)


if you have multiple buttons in your UI Code you can use this nifty function and class to pass extra parameters to tell exactly which button has been pressed as well

(Listenable : listenable(widget_message)).SubscribeMessage(OutputFunc : tuple(widget_message, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_message(t){ExtraData := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
 
wrapper_message(t : type) := class():
    ExtraData : t;
    OutputFunc : tuple(widget_message, t) -> void
    InputFunc(Message : widget_message):void = OutputFunc(Message, ExtraData)

So if you had a few buttons like

button_1: button_quiet = button_quiet{}
button_2 : button_quiet = button_quiet{}

you could use the wrapper function SubscribeMessage to pass which button has been clicked like this

button_1.OnClick().SubscribeMessage(SomeFunction, 0)
button_2.OnClick().SubscribeMessage(SomeFunction, 1)


#then SomeFunction can figure out what to do based on the integer passed into it 

SomeFunction(Message:widget_message, button_index:int):void=
    Player := Message.Player
    if(button_index = 0):
        Item_Granter_0.GrantItem(Player)
    else if(button_index = 1):
        Item_Granter_1.GrantItem(Player)

#or you can have an array of item granters and grab them that way 
@editable Granter_Array :[]item_granter_device = array{}

SomeFunction(Message:widget_message, button_index:int):void=
    Player := Message.Player
    if(Granter := Granter_Array[button_index]):
        Granter.GrantItem(Player)