Page 1 of 1

Scripting a delete command for an object that doesn't exist

Posted: Thu Dec 24, 2009 1:38 am
by mtecedor
Hi All,

I am back again and with a lot of new questions :oops:

I have a button that when is clicked allows the end user to draw a line. I also want the end user to delete the line(s).
Currently, the delete command is scripted within a small image that appears on top of the line after the end user has draw it.
I don't like this method because it is not consistent with the way in which other objects in the screen get deleted, and because the screen gets really cluttered.

What I want:

the end user deletes the line by double clicking on it.

Is this possible? Since the line does not exist yet, I dont know where to put the script.

Any ideas?

This is the srcipt I have up until now:

on mouseUp
put the number of graphics of this card into tGraphicNo
choose graphic tool

--Create a line with the following characteristics
set the style of the templateGraphic to "line"
set the lineSize of the templateGraphic to 2
set the endArrow of templateGraphic to true
set the startArrow of templateGraphic to false
set the arrowSize of templateGraphic to 4
set the foregroundColor of templateGraphic to "blue"

-- put width and height of new line into variable
put the width of templateGraphic into tWidthGraphic
put the height of templateGraphic into tHeightGraphic
--name the new line
set the name of templateGraphic to "lineclone" & tGraphicNo
end mouseUp

Thanks a lot, and happy Xmas

marta

Re: Scripting a delete command for an object that doesn't exist

Posted: Thu Dec 24, 2009 2:26 am
by sturgis
Since I don't know exactly how you have things setup, you may have to adjust this, but you can do it as follows.

Code: Select all

##### This is a button script, think its unchanged from what you posted
on mouseUp
   put the number of graphics of this card into tGraphicNo
   choose graphic tool
   --Create a line with the following characteristics
   set the style of the templateGraphic to "line"
   set the lineSize of the templateGraphic to 2
   set the endArrow of templateGraphic to true
   set the startArrow of templateGraphic to false
   set the arrowSize of templateGraphic to 4
   set the foregroundColor of templateGraphic to "blue"
   -- put width and height of new line into variable
   put the width of templateGraphic into tWidthGraphic
   put the height of templateGraphic into tHeightGraphic
   set the name of templateGraphic to "lineclone" & tGraphicNo
end mouseUp


#####  These are in the stack script, could be card script
on newGraphic
   choose the browse tool  --reverts to browse tool after a line is drawn
end newGraphic

### also in the stack, this checks to see the name of the target clicked, and if it matches your lineclone designation deletes the line.
on mouseDoubleUp
   put the short name of the target
   if the short name of the target contains "lineclone" then
      delete the target
   end if
end mouseDoubleUp
mouseDoubleUp is used because mousedoubleDown always returns the name of the card as far as I can tell.

Re: Scripting a delete command for an object that doesn't exist

Posted: Sat Dec 26, 2009 12:11 am
by mtecedor
Thanks Sturgis,

Putting that code in the card worked great

Marta