'copy card' without going to it? [Workaround found]

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Eoghan
Posts: 9
Joined: Tue Dec 17, 2013 3:38 pm

'copy card' without going to it? [Workaround found]

Post by Eoghan » Mon Mar 31, 2014 4:42 pm

Hi,

I'm using 'copy card x of stack y to this stack' to copy a cached card of a substack of my app, to the main stack.

Is there any way to execute the above command without LiveCode then automatically displaying the copied card x? (as I want the initial card to remain on display)

I can add code to store the initial card ID before the copy, then 'go to card initialCardID' after the copy (and use 'lock screen' to stop the flicker) - but the problem is that the 'closeCard' handler of the initial card fires when the 'copy card' command is executed, and the 'openCard' handler fires when I 'go to card initialCardID'.

I did set a Custom Property to tell the initial card's openCard and closeCard handlers to bail out if they were called during the segment of code that copies cards, but that makes the code quite messy.

Hopefully there's a way to use 'copy card' without LiveCode automatically switching to the new card.

Failing that, is there a way to freeze the messages queue, and then clear it of openCard and closeCard messages, and restart it after the 'copy card' so that those messages are never sent? (I had a look at flushEvents, but I'm not sure it's designed for this)

Attached is a small stack that copies a card from a substack when you press a button. The openCard and closeCard handlers of the initial card display a dialog to show you when they're hit (though this doesn't happen in development mode, so you need to build it as a standalone or before running it).

Anyway, thanks for reading about my issue.

Cheers,
Eoghan.
Attachments
CopyCard.livecode.zip
Copy Card.livecode stack
(1.9 KiB) Downloaded 195 times
Last edited by Eoghan on Sat Apr 05, 2014 5:28 pm, edited 1 time in total.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: 'copy card' without going to it?

Post by Dixie » Mon Mar 31, 2014 4:48 pm

Hi...

You could try something like...

Code: Select all

on mouseUp
   lock screen
   push this card
   go to card "whichever" of stack "whatever"
   -- do all the suff you need to do
   pop card
end mouseUp
Have a look at 'oush' & 'pop' in the dictionary...

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: 'copy card' without going to it?

Post by dave.kilroy » Mon Mar 31, 2014 5:37 pm

I think "oush" should be added to the dictionary :D
"...this is not the code you are looking for..."

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

Re: 'copy card' without going to it?

Post by Klaus » Mon Mar 31, 2014 6:40 pm

Hi Eoghan,
is there a way to freeze the messages queue?
Yes -> "lock messages", that will suppress all "pre-/opencard" handler and everything else, too! :D

Use it like this:

Code: Select all

on mouseUp
   lock screen
   lock messages
   push this card
   go to card "whichever" of stack "whatever"
   -- do all the suff you need to do
   pop card
   unlock messages
end mouseUp
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: 'copy card' without going to it?

Post by dunbarx » Mon Mar 31, 2014 6:44 pm

Hi.

You may have touched on this when you asked if certain messages can be ignored. But wouldn't "lock messages" somewhere in your cloning script do the trick? That handler will, of course, continue to run.

Craig Newman

Eoghan
Posts: 9
Joined: Tue Dec 17, 2013 3:38 pm

Re: 'copy card' without going to it?

Post by Eoghan » Mon Mar 31, 2014 8:05 pm

Fantastic!

Thanks Dixie, Klaus & Craig, for the very speedy replies - a few things I can try out there.

And, yup - I think 'oush' would be a great command to add to LiveCode! Just need to think of a definition ... 'push' for very heavy cards?

Thanks,
Eoghan.

Post Reply