Go to card and preOpenCard message

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Go to card and preOpenCard message

Post by Mag » Wed Aug 13, 2014 1:15 pm

In a standalone I'm using the "Go to card" command to go to the card user leaved when closing the app. In that card I have a preOpenCard handler. All works fine if the user navigate thru the cards but if I use the go to command to go to that card it seems to me that the preOpenCard message is not trigged. Is that command inibite from the go to command o maybe I'm doing something wrong?

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

Re: Go to card and preOpenCard message

Post by Klaus » Wed Aug 13, 2014 2:22 pm

Hi Mag,

no idea what "inibite" means, but it should work! :D

What is in your "pre-/openstack" and "pre-/opencard" handlers?
And WHEN do you fire this "go to cd..."?


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4991
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Go to card and preOpenCard message

Post by dunbarx » Wed Aug 13, 2014 3:00 pm

Klaus.

Inhibit.

Craig

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Go to card and preOpenCard message

Post by Mag » Wed Aug 13, 2014 3:12 pm

Sorry, I meant inhibit...
(thanks Craig! We posted at the same time :D )

The script is in the preOpenStack of the main stack

Code: Select all

on preOpenStack
    put the currentCardWhenClosed of this stack into theCard

    if theCard is not "" then
      go to card theCard
    end if
end preOpenStack
Then in the card I have this script

Code: Select all

on preOpenCard
   updateClock
end preOpenCard

on updateClock
   put the long system time into field "ClockField" of card "Clock"
   put the long system date into field "DateField" of card "Clock"
   
   send "updateClock" to me in (1 - (the long seconds mod 1)) seconds
end updateClock

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

Re: Go to card and preOpenCard message

Post by Klaus » Wed Aug 13, 2014 3:30 pm

Hmmm, nothing unusual, should work! 8)

Does it work if you use "opencard" instead of "preopencard"?

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Go to card and preOpenCard message

Post by Mag » Wed Aug 13, 2014 3:35 pm

Klaus wrote:Hmmm, nothing unusual, should work! 8)

Does it work if you use "opencard" instead of "preopencard"?
Tested also in openCard, it doesn't work (BTW here are lot of other code in preOpenStack and the stack is a clone of the main stack I use as template saved on disk as stack document)

There are alterntives to start the clock without using the openCard/preOpenCard (without user intervention)?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3985
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Go to card and preOpenCard message

Post by jacque » Wed Aug 13, 2014 6:54 pm

Is the clock on a card in the main app or is the app loading a separate stack that contains the clock? If you are opening a separate stack for the second time in the same session, no "open" messages are sent if the stack's destroystack is false. Instead you will get a resumestack message. The "open" messages are only sent the first time the stack loads.

You can either use the resumestack message, or just set destroystack to true on the stack.

If the clock card is in the app itself then your original code should work.

Edit : the open messages are sent normally if you go to another card, they are only omitted from the current card when the stack is resumed. That's because the card is technically already open in memory.
Last edited by jacque on Thu Dec 01, 2016 6:22 pm, edited 1 time in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Go to card and preOpenCard message

Post by Mag » Thu Dec 01, 2016 3:02 pm

Thank you Jacqueline!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Go to card and preOpenCard message

Post by Mag » Sun Jan 15, 2017 2:53 am

Recently I had a similar problem and found that I was handling the preOpenCard in the Stack script, but there was a preOpenCard also in the Card, so the one of the card prevented the one of the stack to trigger. I solved with a "pass preOpenCard" in the card script.

Post Reply

Return to “Mac OS”