Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct way to handle kEventCommandUpdateStatus?



On 8/29/03 4:31 PM, Philip D. Wasson didst favor us with:

> On Friday, Aug 29, 2003, at 15:06 US/Eastern, Eric Schlegel wrote:
>> On Aug 29, 2003, at 11:17 AM, Jim Correia wrote:
>>> If my window can handle 100 commands, then the application also has
>>> to know about those specific 100 command ids so it can disable them
>>> if the event percolates up to the application.
>>> Am I missing something in how this event should be handled
>>> conceptually? Is there a better way to deal with this situation?
>>
>> I hadn't really thought about this particular issue before, but yes,
>> this seems to be a valid concern to me. Your app does need to know
>> about all the command IDs that would need to be disabled if no window
>> is open to implement that command ID. As the set of command IDs grows
>> larger, a simple switch statement could potentially be quite
>> inefficient, depending on what kind of code the compiler generates.
>
> Couldn't the application handler handle the commands it knows about
> (using a switch statement, etc.), and then have a default way of
> dealing with others? For unknown commands, the application could call
> the next handler and if it returns eventNotHandledErr, then nobody is
> dealing with the command, so the menu item can be disabled with
> DisableMenuCommand(). No?

Perhaps not. This is one of those ideas which seems reasonable at first, but
after some thought you realize it's based on the assumption that every
command is updated in a handler. It's possible that something (maybe even
the OS) could install a menu containing items which it wants to always be
available, so it doesn't or can't install a handler to update them. I'm not
suggesting this is the right thing to do, but it could happen. I know my
kEventCommandUpdateStatus handlers get called for some commands in a
TypeIt4Me menu, and I don't know if there's a handler which updates them. To
be completely safe, you should always return eventNotHandledErr for commands
you don't handle.

Larry
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Correct way to handle kEventCommandUpdateStatus? (From: "Philip D. Wasson" <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.