stumped: set script of buttons at runtime - solution A

Frank Leahy frank at backtalk.com
Fri Jun 17 04:22:44 EDT 2005


I would recommend not putting 60 lines of script in your template 
button...doing that means that every time you copy the button all 60 
lines goes with it (10 buttons created means 600 lines of script, etc.) 
  Instead I would do something like this:

on mouseUp
	DoMyCustomButtonMouseUpRoutine
end mouseUp

Then, the "DoMyCustomButtonMouseUpRoutine" handler or function can be 
anywhere in the message path.  What's nice about this is that if you 
use this button in different stacks (or on different cards), each stack 
or card could have its own version of the 
DoMyCustomButtonMouseUpRoutine handler, making the button even more 
versatile.

If you need more control over which routine is called, you could pass 
the name of the button to the DoMyCustomButtonMouseUpRoutine handler 
and then make a decision about which routine to call based on the name. 
  For example:

on mouseUp
	put the short name of me into theShortName
	DoMyCustomButtonMouseUpRoutine theShortName
end mouseUp


Regards,
-- Frank

Web Photos Pro: Software for Photo Bloggers and Other Photo Power Users
See us on the web at http://www.webphotospro.com/

On Jun 17, 2005, at 8:08 AM, use-revolution-request at lists.runrev.com 
wrote:

> From: Rob Cozens <rcozens at pon.net>
> Subject: Re: stumped: set script of buttons at runtime - solution A
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <6.2.1.2.1.20050616115109.01e812d8 at pop3.pon.net>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
>
> Eric,
>
>> The thing I hadn't figured out that lead me down the present path was
>> that I couldn't figure out how to add the script to the template 
>> button.
>
> If you are building the script at runtime, my approach won't work.  If
> you're selecting from a finite number of pre-written scripts, store 
> each
> script in a separate invisible template button.
>
> Rob Cozens



More information about the use-livecode mailing list