'copy card' without going to it? [Workaround found]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
'copy card' without going to it? [Workaround found]
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.
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.
Re: 'copy card' without going to it?
Hi...
You could try something like...
Have a look at 'oush' & 'pop' in the dictionary...
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
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: 'copy card' without going to it?
I think "oush" should be added to the dictionary 

"...this is not the code you are looking for..."
Re: 'copy card' without going to it?
Hi Eoghan,
Use it like this:
Best
Klaus
Yes -> "lock messages", that will suppress all "pre-/opencard" handler and everything else, too!is there a way to freeze the messages queue?

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
Klaus
Re: 'copy card' without going to it?
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
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?
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.
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.