Page 1 of 2
Reopen the stack
Posted: Sun Oct 17, 2021 5:56 pm
by liveCode
How can I make the pile closed? He will ask "Do you want to close?" And if not then he will return the pile?
Re: Reopen the stack
Posted: Sun Oct 17, 2021 6:02 pm
by richmond62
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 (2.84 KiB) Viewed 6472 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
-
Re: Reopen the stack
Posted: Mon Oct 18, 2021 12:32 pm
by liveCode
I need it that if the answer is no, then LiveCode will go back to the stack
That is, when I close the app
Re: Reopen the stack
Posted: Mon Oct 18, 2021 1:11 pm
by richmond62
Try my sample stack and see what happens when you select "No".
Re: Reopen the stack
Posted: Mon Oct 18, 2021 3:30 pm
by liveCode
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
Re: Reopen the stack
Posted: Mon Oct 18, 2021 4:10 pm
by richmond62
That looks very odd to me, I suggest you try to work out how to do that by yourself.
Re: Reopen the stack
Posted: Mon Oct 18, 2021 4:11 pm
by liveCode
What's odd?
Re: Reopen the stack
Posted: Mon Oct 18, 2021 6:06 pm
by richmond62
If there is nothing odd about it you shouldn't have to ask the question.
Re: Reopen the stack
Posted: Mon Oct 18, 2021 6:09 pm
by Klaus
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
Re: Reopen the stack
Posted: Mon Oct 18, 2021 7:57 pm
by liveCode
I want this to happen when someone closes the app on the phone and then it asks if to exit or not
Re: Reopen the stack
Posted: Thu Feb 03, 2022 12:10 pm
by liveCode
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
Re: Reopen the stack
Posted: Thu Feb 03, 2022 12:28 pm
by Klaus
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.
Re: Reopen the stack
Posted: Thu Feb 03, 2022 5:32 pm
by liveCode
It can be detected by on closeStack Was I wrong?
Re: Reopen the stack
Posted: Thu Feb 03, 2022 5:35 pm
by Klaus
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
Re: Reopen the stack
Posted: Thu Feb 03, 2022 6:47 pm
by jacque
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.