Cloning across stacks

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 12:13 pm

This sort of stuff is dead easy:
-
SShot 2023-03-29 at 14.12.25.png
-

Code: Select all

on mouseUp
   clone me
   set the left of the last img to the right of img "Ewe"
   set the top of the last img to the bottom of img "Ewe"
end mouseUp
BUT, being a spoilt child I am not satisfied with that and want things so that when I click on the sheep
it clones onto another stack . . .

BUT . . . Ooooer:
-
SShot 2023-03-29 at 14.17.36.png
SShot 2023-03-29 at 14.17.36.png (19.16 KiB) Viewed 3265 times
Attachments
Dolly the Sheep.livecode.zip
Stack.
(35.23 KiB) Downloaded 43 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 12:31 pm

This MUST be doable as one can do a double-click on an object on the revTools stack to clone
that object across onto one's own stack.

This DOESN'T:

Code: Select all

on mouseUp
   palette "Dolly the Sheep 2"
   wait 5 secs
   copy me
   paste into topStack()
   end mouseUp
and nor does this:

Code: Select all

on mouseUp
   palette "Dolly the Sheep 2"
   wait 5 secs
   copy me
   paste
   end mouseUp
BUT: maybe I'm doing 'things' the wrong way round.

Err . . . NO . . . obviously not:

Code: Select all

on mouseUp
   copy me
   palette "Dolly the Sheep 2"
   wait 5 secs
   paste
   wait 5 secs
   topLevel "Dolly the Sheep 2"
end mouseUp

Klaus
Posts: 13837
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Cloning across stacks

Post by Klaus » Wed Mar 29, 2023 12:44 pm

What's wrong with this one-liner:

Code: Select all

on mouseup
  copy me to stack "the other one"
end mouseup
? 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 1:17 pm

What's wrong with this one-liner:
Nothing, IF one already knows the name of the target stack.

HOWEVER, I have no urge to hard code the name of the target stack into the scripts of objects
on my starter stack.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 1:48 pm

OK: Gotcha:

Code: Select all

on mouseUp
   palette "Dolly the Sheep 2"
   put the short name of the topStack into TPSTK
   topLevel "Dolly the Sheep 2"
   copy me to stack TPSTK 
end mouseUp
-
SShot 2023-03-29 at 15.46.47.png
-
Thank you very much, Klaus.
Attachments
Dolly the Sheep 2.livecode.zip
Stack.
(35.26 KiB) Downloaded 42 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 3:06 pm

My 'oversight', if that's the right word for it, was that I thought a copy command always had to be followed by a paste command.

Code: Select all

on mouseUp
   palette "Dolly the Sheep 2"
   put the short name of the topStack into TPSTK
   topLevel "Dolly the Sheep 2"
   copy me to stack TPSTK 
end mouseUp
That odd little dance where the originating stack is temporarily palettised is so that one can
copy the object to the target stack when one does not know its name: otherwise one ends
up doing what I was doing at the start of this thread and simply duplicating on the originating
stack.

Klaus
Posts: 13837
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Cloning across stacks

Post by Klaus » Wed Mar 29, 2023 4:59 pm

Maybe this will work for you, since a "mouseenter" is also sent if that stack is currently not the topstack.
"t2" is the topstack, button script in stack "t1":

Code: Select all

on mouseEnter
   put the topstack   
end mouseEnter
Bildschirmfoto 2023-03-29 um 17.56.25.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 5:48 pm

My next concern is how to get a 'clone' script into the cardScript so that I don't have replicate that script across 100 different objects.

But, as I am busy cooking a 3 course supper downstairs, my wife having had a fun-packed day of tedious committee meetings and admin. guff, she will come home with an appetite that will be of homeric proportions, things will have to wait a bit.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 6:07 pm

Well, Whacky-Doo: a 2 minute job:
-
SShot 2023-03-29 at 20.05.41.png
-
In the cardScript:

Code: Select all

on mouseUp
   put the target into TARGE
   palette "Target Practice"
   put the short name of the topStack into TPSTK
   topLevel "Target Practice"
   copy TARGE to stack TPSTK
end mouseUp

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 6:10 pm

The next Q is whether things will work if the originating stack is ALWAYS a palette:
-
SShot 2023-03-29 at 20.08.52.png
-
Super . . .

Code: Select all

on mouseUp
   put the target into TARGE
   --palette "Target Practice"
   put the short name of the topStack into TPSTK
   --topLevel "Target Practice"
   copy TARGE to stack TPSTK
end mouseUp

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Wed Mar 29, 2023 6:13 pm

My reason for this is that I should like to make a 'super palette' containing a large number of SVG images
for use inwith LC/OXT for wireframe prototyping . .

I am trying to lay my sweaty paws on ALL the SVGs in LibreOffice Draw to import them into a palette:
as they are Open Source they should be up for grabs, but I am far too lazy to export each one individually from an OO Draw document.

Or, for that matter, from Pencil.

https://pencil.evolus.vn/

Does anyone have any pointers?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9418
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cloning across stacks

Post by richmond62 » Sat Apr 01, 2023 6:55 pm

SShot 2023-04-01 at 20.53.46.png
-
FREE :D
Attachments
Wire Framer.livecode.zip
Stack.
(5.59 KiB) Downloaded 48 times

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”