modal dialogs and Quit problem - also a doc contradiction
Barry Levine
themacguy at macosx.com
Wed Sep 10 09:48:00 EDT 2003
Alex,
I haven't tested the OS9 package yet but I would doubt that the problem
exists anywhere but in OSX specifically because of how Rev creates the
Quit item in the App menu (and ignores the last two items - one being
the divider line above Quit - of the File menu you've crafted in the
menu builder).
Here's what the docs say (I've added one comment in CAPS):
- - - - - -
Special menu items
A few menu items on Mac OS and OS X are handled directly by the
operating system. To accommodate these special menu items while
allowing you to create a fully cross-platform menu bar, Revolution
treats the last two menu items of the Help menu (for Mac OS and OS X),
the File menu (OS X), and the Edit menu (OS X) differently.
By following these guidelines, you can make sure your menus will appear
properly on all operating systems without having to write special code
or create platform-specific menu bars.
The Help menu and the About This Application menu item:
When Revolution sets up the Mac OS menu bar, it automatically makes the
last button the Help menu (regardless of the buttons name). The
standard Help menu items, such as About Balloon Help and Show
Balloons on Mac OS, are included for you automatically; you dont need
to include them in your Help menu button, and you cant eliminate them
from the Help menu.
Revolution moves the last menu item in the Help menu to the About This
Application position. (On Mac OS systems, this is the first menu item
in the Apple menu. On OS X systems, its the first menu item in the
Application menu.) Therefore, the last menu item in your Help menu
button should be an appropriate About item. The menu item above it
must be a divider line (a dash), and above that must be at least one
menu item to be placed in the Help menu.
The File menu and the Quit menu item:
On OS X systems, the Quit menu item is normally placed in the
Application menu (which is maintained by the operating system) rather
than in the File menu as is standard on other platforms. To
acccommodate this user-interface standard, Revolution removes the last
two menu items of the File menu when a standalone application is
running on an OS X system. Therefore, the last menu item in your File
menu button should be Quit. The menu item above it should be a
divider line (a dash).
The Edit menu and the Preferences menu item:
On OS X systems, the Preferences menu item is also normally placed in
the Application menu. To acccommodate this user-interface standard,
Revolution removes the last two menu items of the Edit menu when a
standalone application is running on an OS X system. Therefore, the
last menu item in your Edit menu button should be Preferences. The
menu item above it should be a divider line (a dash).
Note: The Preferences menu item is treated in this special way only
if its name starts with the string Preferences.
Choosing the special menu items:
When the user chooses any of these special menu items, a menuPick
message is sent to the button that the menu item is contained in. This
ensures that your button scripts will work on all platforms, even if
Revolution displays a menu item in a different menu to comply with
user-interface guidelines. (THIS CONTRADICTS OTHER DOCUMENTATION IN
REV; SEE QUOTED TEXT IMMEDIATELY BELOW.)
> On OS X systems, the Quit menu item is part of the Application menu,
> which is displayed by the operating system rather than by the
> application. Because of this, choosing Quit on OS X systems does not
> send a menuPick message, so you cannot handle quitting in a menuPick
> handler.
>
> Instead, choosing Quit sends an Apple Event (class aevt, ID
> quit) to the application. If you dont intercept this Apple Event in
> an appleEvent handler, Revolution sends a shutdownRequest message in
> response to the Apple Event. To respond to the user choosing Quit,
> handle either of these messages.
>
> Tip: For easiest cross-platform development, place all the code you
> want to execute on quitting in a shutdownRequest handler.
(THE PROBLEM IS THAT BOTH THE SHUTDOWNREQUEST HANDLER AND APPLEENVENT
HANDLER ARE IGNORED.)
(BACK TO THE DOCS...)
For example, if the user chooses About This Application from the
Apple menu on a Mac OS system, a menuPick message is sent to the Help
menu button, with About This Application as its parameter. You handle
the message for the About menu item in the Help menu buttons script,
even though Revolution displays this menu item in a different menu on
the Mac.
- - - - -
So the methodology of supporting OSX's special way of displaying
certain menu items has already been defined by Rev; it's just not been
done. We don't need any additional means of referring to the menu items
to disable them as long as the handlers we've defined for them are
called when Rev says they will be (which, currently, they are not).
In my previous post I mentioned that your app's changed data had better
be saved before the user selects Quit in OSX because your app will quit
without warning of unsaved changes. Your shutDownRequest handler would
have, of course, checked a flag to see if a "save changes?" dialog
would be necessary but, as we've seen, selecting Quit simply quits
without sending a shutDownRequest. When Rev puts in the "hook" from the
Quit item to your handler, everything will be fine. Until then, you're
screwed.
Again, I want to emphasize that this problem is only due to the way Rev
moves the OSX menu items so Windows apps work fine and I would expect
OS9 apps to work properly, as well.
Regards,
Barry
On Tuesday, Sep 9, 2003, at 23:06 America/Denver, Alex wrote:
> On Tuesday, September 9, 2003, at 10:37 PM, Richard Gaskin wrote:
>> There may be a way to support OS-specific niceties without losing the
>> unprecedented platform-independent convenience we've been enjoying for
>> years. I would advocate we explore those....
>
> How about: set a property for menu items specifying that should get
> moved into the App menu on OS X. The property could be an integer: the
> menu item's number (placement) in the app menu. If the property is
> empty or zero, it would not get moved to the App menu.
>
> This would be more like other the platform specific features of rev, in
> that other platforms don't suffer, developer is not inconvenienced, but
> we are not prevented from using it.
>
> Does this same problem apply for Mac OS too, or just OS X?
More information about the use-livecode
mailing list