Hi Friends!
Is there some sort of way to process things when a user attempts to leave a card, such as a PreCloseCard handler that I can exit from without closing the card? I read in the Documentation that trapping the CloseCard message does not affect navigation.
Basically, I have a card that has a form on it. If the user leaves the card, but has not clicked the Submit button, I want to prompt them and ask whether they are sure they want to leave the card. If they do, proceed. If not, though, I want the card close behavior to break.
This is probably pretty obvious, but I wasn't able to turn anything up in the Documentation.
Thank ye!
Phil E.
PreCloseCard...?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 212
- Joined: Fri Feb 01, 2013 1:31 am
- Contact:
Re: PreCloseCard...?
What is the action that causes the card to change in the first place?
Maybe you can have an if statement that says something like this,
Maybe you can have an if statement that says something like this,
Code: Select all
local myVar
on GoToOtherCard
if myVar is not "true" then
exit goToOtherCard
else
go to card "Next Card" of this stack
end if
end GoToOtherCard
Re: PreCloseCard...?
Hi Phil,
I think you may have over thought this.
How does the user leave the card?
A button?
Your button?
I haven't tested intercepting "on closeCard" I'll take your word for it. But what calls it?
Simon
I think you may have over thought this.
How does the user leave the card?
A button?
Your button?
I haven't tested intercepting "on closeCard" I'll take your word for it. But what calls it?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: PreCloseCard...?
LiveCode supports a closeStackRequest message because there's at least one action (clicking the window's close box) which could trigger a close over which we have no control in our scripts. Similarly it also has a shutDownRequest message for when any action is taken which could cause your app to quit, which may even be initiated by actions outside your app.
But as William Jamieson suggested, with card-to-card navigation within a stack we normally have complete control over actions that would cause the user to leave a card, where you can do any checking you need before proceeding with the "go" command.
That said, I find the notion of a closeCardRequest message intriguing. Can anyone here come up with use cases where it would be a solution not solvable by other means?
But as William Jamieson suggested, with card-to-card navigation within a stack we normally have complete control over actions that would cause the user to leave a card, where you can do any checking you need before proceeding with the "go" command.
That said, I find the notion of a closeCardRequest message intriguing. Can anyone here come up with use cases where it would be a solution not solvable by other means?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: PreCloseCard...?
Might it be used, as the other "...request" messages are, to prevent card navigation?
The "closeStackRequest" message is not sent if the user executes: "close this stack" from a handler. But "closeCard" is sent, so that should not matter.
Craig
The "closeStackRequest" message is not sent if the user executes: "close this stack" from a handler. But "closeCard" is sent, so that should not matter.
Craig