A question about openCard
dfepstein at comcast.net
Sat Jun 8 09:13:25 EDT 2019
Several people gave helpful replies to my question, including pointing out that this is a case of “resumeStack”, not “openCard”:
Is there some simple way that an openCard handler can branch based on what card it is coming from?
When a user goes to a different card in a stack, or to a different stack, I use an “openCard” handler to set things up. But I do not want those actions taken if the user is merely “returning” to a card after using a palette tool, or after a palette tool has been opened.
Jacqueline Gay suggested using the “recentCards” to determine what card the user is coming from. So I wrote this handler:
-- call this in a "resumeStack" handler.
-- returns true if palette "tTools" has just been active and the resumeStack message was received by the same card that had been active when that palette was activated.
-- returns false if we are coming from a different card, either directly or with a palette activation in between.
get the recentCards
if the long id of stack "tTools" is not in line 2 of it then return false -- nb should work even if palette "tTools" stack has several cards
return line 1 of it = line 3 of it
But this does not work. When I debug, I see that line 2 of the recentCards does not refer to a card on my palette stack (“tTools”); it refers instead to a card in the stack “Execution Contexts”.
Why is that LiveCode system stack appearing in the recentCards, and why is my palette not appearing there?
More information about the Use-livecode