Hi everybody!
On a card in my mainstack I put a button that sends a handler to another stack. There are (currently) two cards in the substack. If the first card is the one open when the user clicks the button, I want to hide some graphics and a field. I'll be adding more code to deal with any further cards.
I was puzzled because the "if" structure was not being evaluated as "true" even though the correct card was open. The handler was correctly executing the lines following the "end if". My theory is that clicking on the button on the mainstack brings that stack to the front, and therefore the card that receives the handler in the substack is not the "current card" because its stack is not the active stack.
Is there a way to refer to the open card of the stack that receives the handler, when that stack is not the current stack?
Is there a way to keep a substack displayed in front of the mainstack when the user clicks on the mainstack, besides opening the substack as a palette?
If I do set the substack to be a palette, will its top card then be the "current card", or will the top card of the mainstack remain the "current card" when the button on it is clicked?
on quitApp
if the name of the current card is "Mock-up" then
hide field "Welcome"
repeat with x= 11020 to 11040
hide image ID x of group "Opening Animation"
end repeat
end if
show image "Springboard.png"
enable button ID 1053
hide image ID 1060
end quitApp
Sending a handler problems
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Sending a handler problems
The problem is that current card returns in this format
card "testCard"
So your test fails to match.
instead you need something like this. There are lots of ways to skin this cat but this one works adequately.
card "testCard"
So your test fails to match.
instead you need something like this. There are lots of ways to skin this cat but this one works adequately.
Code: Select all
on doStuff
put the last word of the name of this card into theCard
replace quote with empty in theCard
if theCard = "testCard" then
put theCard && "It worked!"
end if
end doStuff
Re: Sending a handler problems
if you use the short name instead of the name of the current card it returns just the name, not card "nameOfCard"
the problem with last word is that you can have card names that consist of more than one word.
regards
Bernd
Code: Select all
on doStuff
put the short name of this card into theCard
if theCard = "testCard" then
put theCard && "It worked!"
end if
end doStuff
regards
Bernd
Re: Sending a handler problems
Thanks for the suggestions!
I realized that my handler needed to say "if the short name of the current card..." rather than " if the name of the current card.." After I changed that, the if evaluated without a problem.
I do need to figure out how to keep the substack on top, though, when the user is clicking on the mainstack. Is making it a palette or the only way to do this?

I do need to figure out how to keep the substack on top, though, when the user is clicking on the mainstack. Is making it a palette or the only way to do this?