Is it possible to change OnClick at runtime?

Started by SupSuper, Wed 31/05/2006 16:40:49

Previous topic - Next topic

SupSuper

Is it possible to change a button's OnClick function at runtime? (through code)

Basically, I'm creating a customizable confirm box, and I'd like to be able to change what the Yes button does without having to use Global Variables or some such. Heck, if I could create a Win32 MessageBox function lookalike that returns whatever button is pressed, that'd be grand.
Programmer looking for work

Ashen

#1
You could use a variable inside the OnClick function to change what effect it has, but AFAIK that's the only way to 'change' it's functioning.

Someone (probably SSH) released a confirmation GUI/Module a while back that does pretty much what it sounds like you're after. I can't find it right now unfortunately, but it's out there.

EDIT: OK, apparently it's bundled with SSH's SaveGames with Screenshots Module. You might also be interested in this thread, unless I've misunderstood the question.
I know what you're thinking ... Don't think that.

SSH

It doesn't work very well, though, that one. I've thought about redoing it, recently...
12

edmundito

All you need to do is split what each click does to different functions, and then control them through the onClick. For example, let's say that I when I click the first time ever it does something, but the second time it does something different. Here's a simple solution for that:


short clickturn = 0;

function onClick(...)
{
    if(clickturn == 0) doOneThing();
    else doAnotherThing();
    clickturn = clickturn + 1;
}

SSH

12

SMF spam blocked by CleanTalk