Page 1 of 1

Execute script after cloning an object ?

Posted: Thu May 31, 2018 12:31 am
by raugert
I'm building an application that lets the user clone objects in "pointer mode" using the (opt-click-drag). I would like to add the ID of the newly created object to a datagrid. I'm checking to see if the option key is down and adding the ID to the datagrid but it adds the ID of the original button... The script below is in the original button. I'm pretty sure I'm going about this the wrong way :? Is there another way to trap the opt-click-drag message ?

Code: Select all

on checkOptionKey
   if the eventOptionKey is down then
         select last button
         put the dgNumberOfLines of group "Datagrid" into theLineNo
         put the dgDataOfLine[theLineNo] of group "Datagrid" into theDataA
         put the id of selectedObject into theDataA["ID"]
         dispatch "AddData" to group "Datagrid" with theDataA, theLineNo +1
      end if
end checkOptionKey

Re: Execute script after cloning an object ?

Posted: Thu May 31, 2018 7:48 am
by mrcoollion

Re: Execute script after cloning an object ?

Posted: Thu May 31, 2018 9:35 am
by Klaus
Try:

Code: Select all

on checkOptionKey
   if the eventOptionKey is down then
         ## select last button
         put the dgNumberOfLines of group "Datagrid" into theLineNo
         put the dgDataOfLine[theLineNo] of group "Datagrid" into theDataA
         put the id of THE LAST BUTTON into theDataA["ID"]
         dispatch "AddData" to group "Datagrid" with theDataA, theLineNo +1
      end if
end checkOptionKey
If that does not work, please show us the script which CLONEs the button.

Usually after a cloning the variable IT contains the long ID of the cloned object.
So if you store IT in a variable or custom property you should get this working.

Re: Execute script after cloning an object ?

Posted: Fri Jun 01, 2018 3:58 am
by raugert
thanks Klaus,

That seems to work OK.

Much appreciated,
Richard