Page 1 of 1

Assigning message handlers by script

Posted: Fri Oct 03, 2008 6:17 pm
by kroka
Hello! I am still quite new to Revolution but I am beginning to appreciate it more and more. Coming from traditional programming I had to get used to some of the concepts - but surprisingly it showed that most of the time things worked exactly the way I was thinking about them.

Now I have a problem that I cannot solve on my own. It might be easy or obvious but I can't find anything about it in the documentation:

I am writing a program where some multiple choice options are presented in form of buttons (between 5 and 50) on an extra stack. I create these buttons at runtime dynamically. So far everything is fine. But I want the buttons to react when you click them. So I need to assign some "on mouseDown" script to each of these newly created buttons. How can I do this by script? Or - can I do this at all? If not - which would be the alternative?

Help is very appreciated. Thank you in advance.

Kroka

Posted: Fri Oct 03, 2008 6:51 pm
by kroka
By trying out and reading some of the posts here I came to a solution which is not exactly what I was thinking of but it works for my purpose.

I just assigned a "mouseUp" handler to the card script which analyzes the target and distinguishes the buttons by their labels to react differently for each type of button.

As far as I understand this would be the common way to deal with such things. Am I right? As usual - simple but powerful.

Posted: Fri Oct 03, 2008 8:34 pm
by malte
Hey kroka,

exactly. If you need to do such sort of dynamics, place the script in the card, stack or a library. You could set the script of a button, however that might bit you when it comes to compile time. As soon as you use more than 10 statements in the script you set in a standalone, the scriptlimits will bite you and it will not compile.

Cheers,

Malte

Posted: Fri Oct 03, 2008 8:35 pm
by malte
Und Grüße!

Hast Du schon das deutsche Revolutionboard gesehen?

http://www.revolutionboard.de

Gruß,

Malte

Posted: Sat Oct 04, 2008 7:30 am
by mwieder

Posted: Sun Oct 05, 2008 7:46 am
by kotikoti
Hi Malte,
Please advice on this script limits and where/how the apply to a standalone application.

Kroka, Please check the scipt anatomy discussions @
http://support.runrev.com/scriptingconferences/ contains some details on how to dynamically assign script to objects at runtime.