PreCloseCard...?

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

PreCloseCard...?

Post by Gage » Tue Oct 28, 2014 7:53 am

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.

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: PreCloseCard...?

Post by William Jamieson » Tue Oct 28, 2014 8:29 am

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,

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: PreCloseCard...?

Post by Simon » Tue Oct 28, 2014 8:48 am

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 used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: PreCloseCard...?

Post by FourthWorld » Tue Oct 28, 2014 2:55 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: PreCloseCard...?

Post by dunbarx » Tue Oct 28, 2014 5:33 pm

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

Post Reply