Prompting before "on closeStack"

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Googie85
Posts: 199
Joined: Tue Aug 05, 2014 10:07 am

Prompting before "on closeStack"

Post by 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.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Prompting before "on closeStack"

Post by 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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

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

Re: Prompting before "on closeStack"

Post by Klaus » Thu Sep 14, 2017 9:52 am

Hi Googie,

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


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Prompting before "on closeStack"

Post by 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

Post Reply

Return to “Android Deployment”