Prompting before "on closeStack"

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Prompting before "on closeStack"

Postby Googie85 » Thu Sep 14, 2017 8:44 am

Hi Guys,

I am having some difficulties trying to prompt a user before the app closes when the back button is pressed on a device. The example is as follows:

on closeStack
global timer
put "2" into timer
send "mouseDown" to image "StartButton"
pass closeStack
end closeStack

No matter what I do, the App continues to exit after the back button is pressed.

Any help will be appreciated.

Many Thanks,

Googie.
Googie85
 
Posts: 58
Joined: Tue Aug 05, 2014 10:07 am

Re: Prompting before "on closeStack"

Postby Thierry » Thu Sep 14, 2017 9:45 am

Googie85 wrote:No matter what I do, the App continues to exit after the back button is pressed.


Hi,

You can check in the dictionary: closeStackRequest

Handle the closeStackRequest message if you want to prevent a stack from being closed.


HTH,

Thierry
Thierry Douez - https://sunny-tdz.com
sunnY(rex - text2speech - perl - midi - image - pdf)
Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 560
Joined: Wed Nov 22, 2006 3:42 pm
Location: France

Re: Prompting before "on closeStack"

Postby Klaus » Thu Sep 14, 2017 9:52 am

Hi Googie,

and there is really no need to put NUMBERS into quotes! :D


Best

Klaus
Klaus
 
Posts: 9495
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany

Re: Prompting before "on closeStack"

Postby jacque » Thu Sep 14, 2017 4:36 pm

You need to trap the backKey message. Android OS will quit the app if you don't handle backKey, so you need to handle it on every card. Use it to navigate within the stack the same way any navigation arrows do (if the card has those) or just don't pass the message if you don't want backKey to do anything (but users will hate you if you disable it.)

You can use the same handler you're using now for closeStack and just change the message name to backKey.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
 
Posts: 3798
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN


Return to Android Deployment

Who is online

Users browsing this forum: No registered users and 1 guest