Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Quit menu item on OS X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Quit menu item on OS X



I noticed that all our MAR15b1 based applications are still showing a quit menu item in the application AND file menus when running on OS X and verified this in DemoDialogs as well. Has this been addressed yet for a post b1 release? If not, I've got more info...

My original intent was to fix this in MacApp and contribute the change(s) for incorporation into the next release but I hit a few snags that I'm hoping the list can help with:

I modified TMenuBarManager::InstallPreferredMenus (see below) by adding the code after the call to InstallHelpMenuItems. Is this the best place to do this?

First off, I used the HasAquaMenuLayout_AC call but this always returns true so the quit menu item is always removed even on OS 9. I didn't debug this but just used the four lines after after the HasAquaMenuLayout_AC line (lifted from the Carbon Porting Guide pdf) which works fine. So this code properly removes the quit menu item (and divider line) when running on OS X and leaves it there when running on 8 and 9.

But now when running on X, pressing cmd-Q or selecting quit from the application menu, my application doesn't quit. I made sure I was not removing the command from the command table, i.e I'm not calling DeleteMenuCommand. According to the Carbon Porting Guide it sounds like I need to add a quit AE handler to my application, but MacApp should already be doing this for me, right? Any suggestions or has this already been handled in an upcoming release?



void TMenuBarManager::InstallPreferredMenus()
{
if (((fDisplayedMenus != fPreferredMenuBarID || fDisplayedRegion != fPreferredRegion) && (fPreferredMenuBarID != kNoResource)) || ((fDisplayedHierMenus != fPreferredHierMenuBarID) && (fPreferredHierMenuBarID != kNoResource)))
{
ClearMenuBar();

fDisplayedRegion = fPreferredRegion;

AddMenuBar(fPreferredMenuBarID != kNoResource ? fPreferredMenuBarID : fDisplayedMenus, kNotHierarchical);
fDisplayedMenus = fPreferredMenuBarID;

AddMenuBar(fPreferredHierMenuBarID != kNoResource ? fPreferredHierMenuBarID : fDisplayedHierMenus, kHierarchical);
fDisplayedHierMenus = fPreferredHierMenuBarID;

// We must reinsert the help menus whenever ClearMenuBar is called
gDispatcher->InstallHelpMenuItems();

// Remove the Quit menu item when running on OS X
// if( HasAquaMenuLayout_AC() ) // currently this doesn't work. It's always returning true so the quit menu item is always removed even on OS 9...
long result;
OSErr err;
err = Gestalt(gestaltMenuMgrAttr,&result);
if (!err &&(result &gestaltMenuMgrAquaLayoutMask))
{
// We're running on OS X
short theMenuNumber;
short theItemNumber;

// Get the menu that contains the quit item
CommandToMenuItem(cQuit, theMenuNumber, theItemNumber);

if (theMenuNumber)
{
MenuRef theMenu = MAGetMenu(theMenuNumber);

// Delete the menu item from the menu
if (theMenu)
{
// delete the quit menu item and the divider line above it
::DeleteMenuItem(theMenu, theItemNumber);
::DeleteMenuItem(theMenu, theItemNumber-1);
}
}
}
}
}




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.