My widget_message is not working.

Hi,

I’m trying to use the widget_message struct but its not working like it does in the tutorial. When I try to print the Message.Source like in the tutorial, its blank. My code is below and tutorial code is below that.

HandleSelectedUIButtonExit(Message: widget_message) : void = 
        if (PlayerUI := GetPlayerUI[Message.Player], MyUI := MaybeMyUIPerPlayer[Message.Player]?, SelectedButton := text_button_base[Message.Source]):
            Print("Player selected {SelectedButton.GetText()}")
            PlayerUI.RemoveWidget(MyUI)
            if (set MaybeMyUIPerPlayer[Message.Player] = false) {}
HandleSelectedUIButton(Message : widget_message) : void =
         if (PlayerUI := GetPlayerUI[Message.Player], MyUI := MaybeMyUIPerPlayer[Message.Player]?, SelectedButton := text_button_base[Message.Source]):
             Print("Player selected {SelectedButton.GetText()}")
             PlayerUI.RemoveWidget(MyUI)
             if (set MaybeMyUIPerPlayer[Message.Player] = false) {}

But when I press the button in game, its blank( image below).
image

The tutorial shows this.

I’m using a signal_remote_device to initiate the widget but I wouldn’t think that difference is causing this.

2 Likes

same problem here!

I managed to get the value to be printed by declaring the button and the text at the start and assigning 2 different texts

    # Two text
    TextDefault<localizes> : message = "Button1"
    AlternativeText<localizes> : message = "Button1"
    # Button to assign
    var Button1: button_loud = button_loud{}

   OnBegin<override>()<suspends>:void=
         # define on Begin
         set Button1= button_loud{DefaultText := TextDefault}
    
    # And creating the UI
    CreateMyUI() : canvas =        
        Button1.SetText(AlternativeText)
        Button1.OnClick().Subscribe(HandleSelectedUIButton)

I tried this and it worked! Thanks for the help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.