What are the default values for the templateGraphic

Scott Rossi scott at tactilemedia.com
Fri Nov 26 12:03:35 EST 2004


Recently, Jim Hurley wrote:

> I've discovered I don't understand the templateGraphic. In the docs it says:
> 
> Use the templateGraphic keyword to set up default properties to be
> used for any new graphics you create.....The properties of the
> templateGraphic are reset to their defaults when all running handlers
> finish executing.
> 
> However the following handler give me a circle whose foregroundcolor is white.
> 
> local x0,y0
> 
> on circle radius
>  reset templateGraphic
>  if there is no graphic "myCircle" then create graphic "myCircle"
>  set the style of graphic  "myCircle" to  oval
>  set the  rect of graphic "myCircle" to
> x0-radius,y0-radius,x0+radius,y0+radius
> end circle
> 
> This implies that the default value of the foregroundcolor of the
> templateGraphic is white. At least for this particular stack. I can,
> of course, set the foregroundcolor to black--but only after the
> "reset templategraphic." (I did have an earlier problem with this
> stack--it did appeared that all the foregroundcolors were set to
> white throughout the stack. Maybe the stack is corrupted.)
> 
> If I create a new stack, the same handler gives me a black
> foregroundcolor for the circle.
> 
> Are there default values for the templateGraphic that apply to the
> *stack*? How would one get the default values of the templateGraphic?

The templateGraphic is used to set properties of any graphic you create
*before* you create it.  In the above example, you should be able to set
your properties before calling "create graphic".  "resetGraphic" is usually
called after changing the template to restore the template object to
"normal".

Try this:

 on circle radius
  if not there is a graphic "myCircle" then
    set the style of the templateGraphic to oval
    set the  rect of the templateGraphic to \
       x0-radius,y0-radius,x0+radius,y0+radius
    set the name of the templateGraphic to "myCircle"
    create graphic
    reset the templateGraphic
  end if
 end circle


Regards,

Scott Rossi
Creative Director
Tactile Media, Development & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com



More information about the use-livecode mailing list