How to call a function through a function paramater

Posted By: msmith2468

How to call a function through a function paramater - 06/09/12 01:09

Basically I am trying to make my own button. Everything works great but I want to specify a function to be called when the button is pressed.

for example

functing MikesBtn(var SIZEX, var SIZEY, VOID* LeftClickFunction){
if(Left click){Run LeftClickFunction};
}

Basically when I define a button I want to specify what action it should take when the button is pressed. I would also like to include parameters in the functions I call.

The built in button function has this ability to specify the function. I can not seem to figure out what to do. Thanks for the help.
Posted By: MasterQ32

Re: How to call a function through a function paramater - 06/09/12 11:46

use a dummy function:

void mybuttonfunc(void);

functing MikesBtn(var SIZEX, var SIZEY, VOID* LeftClickFunction)
{
if(Left click)
{
mybuttonfunc = LeftClickFunction;
if(mybuttonfunc) mybuttonfunc();
}
}

Posted By: FoxHound

Re: How to call a function through a function paramater - 06/09/12 18:23

That should work and will work fine with the 3dgs button setup. Don't make the game making any harder than it has to be by reinventing the wheel here.
Posted By: msmith2468

Re: How to call a function through a function paramater - 06/11/12 19:15

Thanks a lot!

@FoxHound - I do not intend to reinvent the wheel. The built in button function is very useful. All I am doing Is remaking the wheel to see and thoroughly understand how it works. I have already learned much from my own button design. I do not expect my button to be better or more efficient then the built in button function but there is a special satisfaction in creating something of your own. I know everything about my button because I built it. If I do not like something I can change it. Instead of trying to find a hack job work around for something someone else built.

I have so far created my button to be built from scratch when the function is called. An image with the size, color, location specified is created and the button responds to, mouse over, left click, and right click.

Thanks for the help and comments!
Posted By: FoxHound

Re: How to call a function through a function paramater - 06/11/12 19:46

There are plenty of things about 3dgs that I don't like but the button system in the panels is not one of them.

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=402345#Post402345

The things I do with buttons in this thing, plus panel pointers when you click the buttons is a bit over the top.

However learning how to make a button from scratch is a pretty good way to learn in depth programming and I salute that.
© 2024 lite-C Forums