Just another way to explain it:Regarding my own code, I remain unconvinced that it is not a bug in LC, but saying it isn't faulty when there seems no logical reason why a default rectangle should be added on the second click when it works as expected on the first click.
When you create a new control from script, LC gives it some default properties. Your handler then adjusts the defaults to make the control look like you want. The default shape for a graphic is a rectangle.
When you refer to a control by name, LC has to search all the controls for a matching name. It starts with the first one and keeps looking until it finds one with the correct name. Once found, it applies whatever you've scripted to that control.
On the first click of the button there are no other graphics named tLine so the properties you set are applied to the first graphic. On the second click, LC searches through the graphics in numerical order until it finds one named tLine, which is still the first one, and sets the properties on that one. As long as all your graphics have the same name, LC will always stop looking when it finds the first one.
There are three ways to avoid this as posted above. Another way to fix the problem is to refer to the last graphic, which will always be the one most recently created. LC won't scan through the earlier ones in that case, it will use the one you intended.
Code: Select all
set the style of last grc to "line"