Why can't the function build?

Hi everyone

i need some help on one of the following function:

CreateButton(_BackgroungTexture:texture, _ContentText : string, _Callback(: widget_message) : void) : canvas =
{
    var btnCanvas : canvas = canvas{}
    btnContent : button_slot = CreateWidgetContent(_BackgroungTexture, _ContentText)        

    case (m_ButtonSetting.GetFontType())
    {
        EButtonFont.None =>
            var btn : button = button{Slot := btnContent}
            btnCanvas.AddWidget(GetDefaultCanvasSlot(btn))
            btn.OnClick().Subscribe(_Callback)
            
        EButtonFont.Loud =>
            var buttonLoud :  button_loud = button_loud{DefaultText:=StringToMessage(_ContentText)}
            buttonLoud.OnClick().Subscribe(_Callback)
            btnCanvas.AddWidget(GetDefaultCanvasSlot(buttonLoud))
            btnCanvas.AddWidget(GetDefaultCanvasSlot(btnContent.Widget))

        EButtonFont.Regular =>
            var buttonRegular :  button_regular = button_regular{DefaultText:=StringToMessage(_ContentText)}
            buttonRegular.OnClick().Subscribe(_Callback)
            btnCanvas.AddWidget(GetDefaultCanvasSlot(buttonRegular))
            btnCanvas.AddWidget(GetDefaultCanvasSlot(btnContent.Widget))

        EButtonFont.Quiet =>
            var buttonQuiet :  button_quiet = button_quiet{DefaultText:=StringToMessage(_ContentText)}
            buttonQuiet.OnClick().Subscribe(_Callback)
            btnCanvas.AddWidget(GetDefaultCanvasSlot(buttonQuiet))
            btnCanvas.AddWidget(GetDefaultCanvasSlot(btnContent.Widget))
    }
    
    return btnCanvas
}

because when I try to build my scripts I have this error:
Script error 3502: Using a value of type type{(:t->void):cancelable} as a value of type type{(:widget_message->void):cancelable} is not yet implemented.

In fact I have four errors but it’s four times the same on different lines ^^’

In summary, I would like to be able to register a function in the Onclick event as part of the parameters of my function which constructs my button!

I’m not sure I’m very clear in my explanations ^^’

if anyone has a solution to solve my error or another method to do this!
I’m open to ideas ^^

Thanks in advance ^^

1 Like

your callback function has a wrong type, maybe use type alias and define the function type as needed

I think it’s a bug, I’m having the same issue here

parametric_class(t:type) := class<computes>:
    SomeMethod : tuple() -> t

ReturnInt():int=0

SomeParametricClassInt : parametric_class(int) = parametric_class(int):
    SomeMethod := ReturnInt # Script error 3502: Using a value of type tuple()->int as a value of type tuple()->t is not yet implemented.

Hi

Thanks for your answer I will test your solution when I need a callback in a function again ^^

Basically the origin of my problem is that I created full verse UI because I need to call on data in the latter
But the button that I created is not usable with a controller

So my current problem is to know how to read data on the verse in a umg or how to create totally custom ui buttons interactable by the controller

But I will create another post for that :wink: