Page 1 of 1

Does MakeButton() have to return ID as a last thing?

Posted: Fri Oct 10, 2025 9:17 pm
by Bugala
Is there any technical reason that MakeButton Returns the ID as a last thing, as in:

Code: Select all

ID = MakeButton(NIL, X, Y...)
Doesnt it anyway reserve the memoryspace as a first thing, hence it could return it as a first thing too?

My question is related to the situation where I would want to use this returned value already when declaring the button.

As in:

Code: Select all

IButtonD = MakeButton(Nil, X, Y, {MyFunc=Function() ButtonFunc(ButtonID) EndFunction) )
I know this is unconvential, and I do have a workaround for this, but I would rather if it could simply work with the before mentioned code to make the code much simpler and not rely on workaroundrefs.

Re: Does MakeButton() have to return ID as a last thing?

Posted: Sat Oct 11, 2025 2:18 pm
by airsoftsoftwair
Bugala wrote: Fri Oct 10, 2025 9:17 pm My question is related to the situation where I would want to use this returned value already when declaring the button.

As in:

Code: Select all

IButtonD = MakeButton(Nil, X, Y, {MyFunc=Function() ButtonFunc(ButtonID) EndFunction) )
The ID of the button will be passed to your callback so you can just do the following to access it:

Code: Select all

ButtonID = MakeButton(Nil, X, Y, {MyFunc=Function(msg) ButtonFunc(msg.id) EndFunction})

Re: Does MakeButton() have to return ID as a last thing?

Posted: Sat Oct 11, 2025 10:08 pm
by Bugala
Good point, forgot it does that.

Going to check if I can take advantage of that, since I have my own custom MakeButton function.