cloning group

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
billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

cloning group

Post by billworld » Tue Mar 13, 2012 5:02 pm

I have a project for which I was advised to clone grouped objects. There are many dozens of these groups. To keep the design of the project manageable, I need to place each group on its own card. I then need to place individual groups on the main card. Doing so via the code below causes the card window to flicker as cards are switched. How do I prevent the flicker?

Code: Select all

on mouseUp
   go to card Task
   clone invisible group Task2
   set name of it to Task3
   place it on card Main
   go to card Main
   set the visible of it to true
end mouseUp

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cloning group

Post by Klaus » Tue Mar 13, 2012 5:21 pm

Hi Bill,

a "lock screen" should do the trick and please do yourself a favour and get used to put QUOTES around strings and names! 8)

Code: Select all

on mouseUp
   lock screen
   go to card "Task"
   clone invisible group "Task2"
   set name of it to "Task3"
   place it ONTO card "Main"
   go to card "Main"
   set the visible of it to true
end mouseUp
Best

Klaus

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: cloning group

Post by billworld » Tue Mar 13, 2012 5:45 pm

Excellent. Thanks Klaus.

Also, is there a way to move the grouped vs just placing it on the new destination card? Placing it keeps a cloned copy on the source card. What I'd really like to do is simply move it. I searched the dictionary for "move" but that seems to show unrelated commands. Also attempting to delete the cloned group from the source card brings up a dialog to delete all instances of the cloned group. Need help understanding how to move the cloned group from card to card.

Thanks for the help!

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: cloning group

Post by billworld » Tue Mar 13, 2012 5:48 pm

Also, yeah I'm aware of the need to quote literals, but I recalled reading about how LiveCode allows you to code without all the extra punctuation marks... so, I thought I'd try to see how it works in this respect. Anyway, I agree to be safe and to ensure the correct values are referenced literals should always be quoted. Thanks for pointing that out!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: cloning group

Post by mwieder » Tue Mar 13, 2012 6:14 pm

Also, is there a way to move the grouped vs just placing it on the new destination card?

Code: Select all

copy group "Task2" of card "Task" to card "Main"

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cloning group

Post by Klaus » Tue Mar 13, 2012 6:20 pm

Hi Bill,

instead of cloning and then pacing, you could eventually just COPY the group(s) to the target card!?
...
lock screen
copy grp "my group A" of cd "xyz" to cd "the current one or whatever"
set the loc of grp "my group A" of cd "the current one or whatever" to X,Y
...

On the other hand, PLACING does not put a COPY of the original group on the card!
It IS in fact the original (in your case CLONED) group! :D


Best

Klaus

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: cloning group

Post by billworld » Tue Mar 13, 2012 6:23 pm

Thanks! Looks like the advice I received to clone was errant as what I really need was to copy. If there are intermediary steps such as resizing the group, is there a special way of handling that before it gets displayed thus avoiding any flicker visual distractions?

Thanks much.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cloning group

Post by Klaus » Tue Mar 13, 2012 6:29 pm

Hi Bill,

just:
...
lock Screen
## do your resize etc. stuff here
...
will do :-)


Best

Klaus

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: cloning group

Post by billworld » Tue Mar 13, 2012 6:30 pm

OK I see how lock screen prevents flicker during any intermediary steps. Thanks for the quick help.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cloning group

Post by Klaus » Tue Mar 13, 2012 6:40 pm

Yes, then the screen will be refreshed after a "unlock screen" or the end of the current handler!

Post Reply