Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / December 2003



Tip: Looking for answers? Try searching our database.

Apple menu prob under 10.3

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
brucecoughlin - 16 Dec 2003 08:11 GMT
I'm having a strange problem which I don't THINK was a problem under 10.2

C app CW9 Mach-0

When I start up my app just after inits etc the Apple Menu is slightly
trashed. The Log Out item (last menu item in the Apple menu) says

"Log Out %@..."

with %@ instead of my user/login name. Other apps running at the same time
have the correct wording there.

In my Carbon Events handler I have the following for menus.

       case kEventClassMenu:
           if(eventKind == kEventMenuEnableItems)
           {
               GetWindowClass(FrontWindow(),&windowClass);
               if(windowClass == kDocumentWindowClass)
                   MaintainMenus();
               result = noErr;
           }
           break;

If I comment out "result = noErr" then the Log Out item does NOT get
trashed. If I leave it in, the Log Out item gets changed.

Any hints?

TIA
Miro Jurisic - 16 Dec 2003 08:29 GMT
> In my Carbon Events handler I have the following for menus.
>
[quoted text clipped - 12 lines]
>
> Any hints?

By always returning noErr, you are claiming that you always handle enable items
events for every menu in your application, which is wrong. This means that the
system handler is never called, and so you steal the OS's chance to handle its
menus. You should only return noErr when you handle the event for one of your
own menus.

Also, you should install this handler on your windows, not on your application,
since you are clearly only interested in handling the event if one of your
windows is in the target chain.

If you want to have a handler which provides a default behavior beyond the
default OS behavior, you should call through to the next event handler in the
chain, and if it returns eventNotHandlerErr, apply your default behavior.

meeroh

Signature

If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist>

James Meiss - 16 Dec 2003 22:42 GMT
> I'm having a strange problem which I don't THINK was a problem under 10.2
>
[quoted text clipped - 22 lines]
> If I comment out "result = noErr" then the Log Out item does NOT get
> trashed. If I leave it in, the Log Out item gets changed.

Indeed, this was news to me too. It seems that for a kEventClassMenu the
EventParameter is a menuRef, and you are supposed to check the menuRef
and set result = eventNotHandledErr when it is not one of your menus. It
seems that you get an EnableEvent for each of your menus, and other
system menus, such as the apple menu, and perhaps other "menulets" too.

I agree that I don't recall any problems with this under Jaguar...
I believe that this breaks the nice sample codes in Bricknell's
"Macintosh C Carbon" book too.

Signature

James Meiss
<http://amath.colorado.edu/faculty/jdm>

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.