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.
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 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23320.0) Module. You might also be interested in this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23869.0), unless I've misunderstood the question.
It doesn't work very well, though, that one. I've thought about redoing it, recently...
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;
}
For a customisable confirm box, try my new DialogBox module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26842.0)