Closing main stack and reopening from dock
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Closing main stack and reopening from dock
I am working on my first LiveCode application and it is intended to be cross-platform.
My primary platform is Windows, and there is one behavior on Mac OS X that I haven't figured out how to handle.
When I close the main stack on Windows, for example by clicking the "X" on the main stack window, the application is terminated completely.
When I close the main stack on OS X by clicking the red little circle on the main stack window, the stack window is closed, but the app is not terminated. It just seems to be suspended, or whatever state it is in. And the app icon is still on the dock and shows that the app is active.
How can I reopen the stack window when the user clicks the app icon on the dock while the app is in this state? That's what native OS X apps seems to do, but I haven't been able to figure out what message I might need to trap or what else I might need to do to accomplish that.
Thanks for any insights!
My primary platform is Windows, and there is one behavior on Mac OS X that I haven't figured out how to handle.
When I close the main stack on Windows, for example by clicking the "X" on the main stack window, the application is terminated completely.
When I close the main stack on OS X by clicking the red little circle on the main stack window, the stack window is closed, but the app is not terminated. It just seems to be suspended, or whatever state it is in. And the app icon is still on the dock and shows that the app is active.
How can I reopen the stack window when the user clicks the app icon on the dock while the app is in this state? That's what native OS X apps seems to do, but I haven't been able to figure out what message I might need to trap or what else I might need to do to accomplish that.
Thanks for any insights!
Re: Closing main stack and reopening from dock
Hi,
For example:
but this is a bit rigorous. You should read up on closeStackRequest and shutDownRequest in the dictionary. Later you might also try to learn more about Apple events (search for appleEvent in the dictionary).
Kind regards,
Mark
For example:
Code: Select all
on closeStackRequest
quit
end closeStackRequest
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Closing main stack and reopening from dock (appleEvent)
Hi Mark, thank you very much, your pointers allowed me to solve the issue the right way!
I added a handler for appleEvents to the app, and now it works as it should. In this case I am only handling the "rapp" event that is sent when an app is reopened, as the events for open and quit seem to be handled by LiveCode automatically.
I added a handler for appleEvents to the app, and now it works as it should. In this case I am only handling the "rapp" event that is sent when an app is reopened, as the events for open and quit seem to be handled by LiveCode automatically.
Code: Select all
on appleEvent theClass,theID
switch
case theClass is "aevt" and theID is "rapp"
go to card "MyCard" of stack "MyStack"
default
pass appleEvent
end switch
end appleEvent
Re: Closing main stack and reopening from dock
Hi,
You solved it very nicely, but a simplel if statement instead of a switch structure would have been sufficient.
Kind regards,
Mark
You solved it very nicely, but a simplel if statement instead of a switch structure would have been sufficient.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Closing main stack and reopening from dock
By the way, the MacTech Journal has a book online: "MACINTOSH C: A Hobbyist's Guide To Programming the Mac OS in C".
Chapter 10 of it explains appleEvents.
Even though the book is already pretty old, I found it very helpful in getting a basic understanding of the topic.
It seems I am not allowed to post links here, but you should be able to find it pretty easily if you want to take a look.
Chapter 10 of it explains appleEvents.
Even though the book is already pretty old, I found it very helpful in getting a basic understanding of the topic.
It seems I am not allowed to post links here, but you should be able to find it pretty easily if you want to take a look.
Re: Closing main stack and reopening from dock
Yeah, when I started writing the handler, I expected to handle more than one appleEvent, hence the switch statement.
I left it in place even though at this time I actually only needed to handle the rapp.
I left it in place even though at this time I actually only needed to handle the rapp.
Re: Closing main stack and reopening from dock
Hi,
Don't worry, both ways work fine
Mark
Don't worry, both ways work fine
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode