Go Command Does not Execute OpenCard on Destination Card

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
Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Go Command Does not Execute OpenCard on Destination Card

Post by Gage » Wed Dec 10, 2014 12:29 am

Hi all,

I have had an issue in a couple of apps where the first card of a stack does not have its OpenCard handler automatically execute when I get there using the Go command to get to the stack. Is this an intentional behavior of LiveCode?

At the moment, it is hurting me, because I am trying to populate a DG on that card, but without hitting the OpenCard handler, old data is still displayed, and I have not yet made some sort of workaround to force the OpenCard handler.

Thanks!
Phil E.

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

Re: Go Command Does not Execute OpenCard on Destination Card

Post by dunbarx » Wed Dec 10, 2014 2:15 am

Hi.

If the card is already open, no opencard message will be sent. If the stack that the card of interest is open, but you are on another card in that stack, then it will. If the stack is not open, it certainly should.

Any of this help?

Craig Newman

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Go Command Does not Execute OpenCard on Destination Card

Post by Gage » Wed Dec 10, 2014 3:04 am

Craig, I think so...

So, in HandlerA, I have this line to initialize the destination stack:
start using stack "My Stack"

A short while later, in HandlerB, I have a line that says:
go to card "My Card" of stack "My Stack"


By initializing it thus, have I opened the stack in the background and prevented myself from being able to execute the OpenCard handler when I do bring stack "My Stack" to the forefront?

Thanks for your reply!
Phil E.

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

Re: Go Command Does not Execute OpenCard on Destination Card

Post by dunbarx » Wed Dec 10, 2014 4:23 am

Sounds like it.

Have you played with the "resumeStack" message"? Placed in the stack script, it will fire whenever you return to an open stack. A handler that traps that message can do whatever you need. Another way, though a kluge, would be to go to a different card in your target stack than the one of interest, and then go to the target card. Hiding the screen is a good idea here.

Anyway, this is normal behavior in LC. But there are simple ways around it.

Craig

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: Go Command Does not Execute OpenCard on Destination Card

Post by Gage » Wed Dec 10, 2014 4:28 am

Craig,

Alright, thanks so much for the insight. I have a good grasp on it now.

I also found out that, while my OpenCard script was not running because of this, my actual real issue was not resolved even when I force the OpenCard.

For some reason, my DataGrid is not refreshing when I set its dgData, yet the data array has been created properly, and the script even continues past the "set the dgData of ..." line. Strange.

It's kind of an enigma, but I'll keep hammering away at it. Maybe the workaround you suggested will miraculously make that work too, in the case that the way I come to the card prevents the DG from being recognized or regrettable...

In any case, thanks again!

Phil E.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Go Command Does not Execute OpenCard on Destination Card

Post by SparkOut » Wed Dec 10, 2014 8:38 am

Perhaps try emptying the datagrid before setting the new data. Then you might be able to determine whether the problem is in the data array or with the reference to the datagrid being populated, depending on the grid being empty or retaining the old data.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Go Command Does not Execute OpenCard on Destination Card

Post by FourthWorld » Wed Dec 10, 2014 3:40 pm

It may be helpful to check the state of the lockMessages property at the moment the event you're looking for isn't being fired.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply