Reopen the stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Reopen the stack

Post by liveCode » Sun Oct 17, 2021 5:56 pm

How can I make the pile closed? He will ask "Do you want to close?" And if not then he will return the pile?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reopen the stack

Post by richmond62 » Sun Oct 17, 2021 6:02 pm

One or 2 odd things here:

1. What do you mean by a 'pile'?

2. Isn't 'livecode' an odd user name?

Anyway, as far as I can understand from your posting let's imagine a button:
-
SShot 2021-10-17 at 19.58.41.png
SShot 2021-10-17 at 19.58.41.png (2.84 KiB) Viewed 4527 times
-
and let's give it some code:

Code: Select all

on mouseUp
   answer "Do you want to quit?" with "Yes" and "No"
   if it is "Yes" then
      quit
   end if
end mouseUp
-
SShot 2021-10-17 at 20.01.20.png
Attachments
QUITTER.livecode.zip
Here's the stack.
(804 Bytes) Downloaded 115 times

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Mon Oct 18, 2021 12:32 pm

I need it that if the answer is no, then LiveCode will go back to the stack
That is, when I close the app

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reopen the stack

Post by richmond62 » Mon Oct 18, 2021 1:11 pm

Try my sample stack and see what happens when you select "No".

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Mon Oct 18, 2021 3:30 pm

Nothing happens but I need when exiting the app then it will go back in about such a code:
on closeStack
answer "exit?" with "no" and "yes"
if it is "no"
then
// Return to the app
end if
end closeStack

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reopen the stack

Post by richmond62 » Mon Oct 18, 2021 4:10 pm

That looks very odd to me, I suggest you try to work out how to do that by yourself.

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Mon Oct 18, 2021 4:11 pm

What's odd?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Reopen the stack

Post by richmond62 » Mon Oct 18, 2021 6:06 pm

If there is nothing odd about it you shouldn't have to ask the question.

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

Re: Reopen the stack

Post by Klaus » Mon Oct 18, 2021 6:09 pm

Hi livecode,

welcome to the forum!

To learn more about the basics of Livecode, I recommend these stacks:
http://www.hyperactivesw.com/revscriptc ... ences.html

If the user wants to close a window via the button in the title bar, the -> closestackrequest
message is sent to LC. So just put this into the stackscript:

Code: Select all

on closestackrequest
   answer "Really close the stack?" with "no" and "yes"
   if it = "yes" then
     # we let the message pass, so LC will close the stack:
    pass closestackrequest
  end if
  ## No need to take action if user clicks "no", understand why?
end closestackrequest
Best

Klaus

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Mon Oct 18, 2021 7:57 pm

I want this to happen when someone closes the app on the phone and then it asks if to exit or not

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Thu Feb 03, 2022 12:10 pm

When the user closes the app on the phone then even if he clicks "No"
Then it will close because the phone closes the app

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

Re: Reopen the stack

Post by Klaus » Thu Feb 03, 2022 12:28 pm

I am afraid we cannot do this on the mobile platform!
Because the user can use the hardware button on the phone and we cannot "trap" this.

liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

Re: Reopen the stack

Post by liveCode » Thu Feb 03, 2022 5:32 pm

It can be detected by on closeStack Was I wrong?

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

Re: Reopen the stack

Post by Klaus » Thu Feb 03, 2022 5:35 pm

No, but this does not work as expected on mobile, as you already experienced:
When the user closes the app on the phone then even if he clicks "No"
Then it will close because the phone closes the app

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

Re: Reopen the stack

Post by jacque » Thu Feb 03, 2022 6:47 pm

liveCode wrote:
Thu Feb 03, 2022 5:32 pm
It can be detected by on closeStack Was I wrong?
The closeStack message is sent when the app is quitting. It allows you to do some things before it shuts down. For example, you can use that message to save user preferences to a file, or to reset controls on the card. But the message does not allow you to stop the shutdown because it is already happening.

If you have a Quit button you can control the shutdown by using Klaus' handler. But as he said, you can't control the hardware phone button behavior.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”