stumped: set script of buttons at runtime

Eric Chatonet eric.chatonet at sosmartsoftware.com
Thu Jun 16 11:50:31 EDT 2005


Hi Emilio,

As you say:

> However, if I open the stack using the "go" command from within  
> another stack, the above makeButton command does not set the script  
> property of the buttons and hence none of them work.

I guess it's a "defaultStack" issue: your script does not find the  
button "defaultButton" of card "defaultBlock" because this button is  
located in another stack.
Try something like button "defaultButton" of card "defaultBlock" of  
stack "defaultStack"
Hope this helps.

Best Regards from Paris,

Eric Chatonet.

> Hi All,
> I've been battling this problem for a few days and have no idea  
> where to look next.  Originally I thought it had to do with global  
> variable issues between stacks.  However, after MUCH hair-pulling  
> it appears the problem has to do with setting the script property  
> of buttons dynamically ...or so I think...Keep in mind the  
> following code works perfectly in development.  That is, the last  
> line of the mouseUp handler in the hidden defaultButton says  
> "answer the script of me".  In development, after all the buttons  
> have been created, clicking any of the buttons generates a dialog  
> box and the appropriate script.  In standalone mode, the script of  
> all the dynamically created buttons is empty...even the "answer"  
> command on the last line on makeButtons returns empty
>
>
> on makeButton buttonText
>
>   set the style of the templateButton to "Button"
>   set the label of the templateButton to buttonText
>   set the visible of the templateButton to false
>   set the width of the templateButton to BUTTON_WIDTH
>   set the height of the templateButton to BUTTON_HEIGHT
>   set the opaque of the templateButton to false
>   set the textAlign of the templateButton to "center"
>   set the threed of the templateButton to false
>   set the showborder of the templateButton to false
>   set the autohilight of the templateButton to false
>   set the textFont of the templateButton to "verdana"
>   set the textSize of the templateButton to "16"
>   set the location of the templateButton to DEFULT_LOCATION
>
>   lock messages
>   create button buttonText
>   unlock messages
>
>   set the script of button buttonText to the script of button  
> "defaultButton" of card "defaultBlock"
>   set the location of it to getNextButtonLocation()
>   set the myHome of it to the location of it
>
>   set the visible of button buttonText to true
>   answer the script of button buttonText
>
> end makeButton
>
> All the buttons are exactly the same except for their label.  They  
> all have the same functionality so i store the script for the  
> buttons in a button whose visibility is set to false.  In  
> development mode everything works perfectly.  All the buttons  
> appear, they all contain the script from the hidden button, and  
> they all use their respective scripts as intended.  However, if I  
> open the stack using the "go" command from within another stack,  
> the above makeButton command does not set the script property of  
> the buttons and hence none of them work.  If I set the visibility  
> of the original hidden button to true, it works fine.  So for some  
> reason, setting the script of a button at runtime does not seem  
> possible.  Does anyone know what I'm doing wrong here??

----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        eric.chatonet at sosmartsoftware.com/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------



More information about the use-livecode mailing list