Page 1 of 1

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

Posted: Mon Mar 31, 2014 4:42 pm
by Eoghan
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.

Re: 'copy card' without going to it?

Posted: Mon Mar 31, 2014 4:48 pm
by Dixie
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...

Re: 'copy card' without going to it?

Posted: Mon Mar 31, 2014 5:37 pm
by dave.kilroy
I think "oush" should be added to the dictionary :D

Re: 'copy card' without going to it?

Posted: Mon Mar 31, 2014 6:40 pm
by Klaus
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

Re: 'copy card' without going to it?

Posted: Mon Mar 31, 2014 6:44 pm
by dunbarx
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

Re: 'copy card' without going to it?

Posted: Mon Mar 31, 2014 8:05 pm
by Eoghan
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.