Need validateMenu instead of validateMenuItem
Need validateMenu instead of validateMenuItem
- Subject: Need validateMenu instead of validateMenuItem
- From: Daniel Jalkut <email@hidden>
- Date: Wed, 15 Jan 2003 10:35:56 -0800
I am trying to dynamically update the contents of an NSStatusItem menu.
With an NSStatusItem, the menu is set and all display is handled by the
UIServer. This leaves me (as I see it) with two choices for dynamic
updates:
1) Install a timer and update periodically. Obviously this can suck
because you can lag the user's actions if you're not careful.
2) Update on some notification from the system.
I'm trying to update on a notification from the system, but the best I
can find is validateMenuItem. I saw that mentioned as an appropriate
solution for this problem in an archived mailing list message.
Using validateMenuItem as an opportunity to rebuild an entire menu
seems like a kludge, and if the "rebuild" action is non-trivial, the
added cost of rebuilding for every item can be prohibitive. The way my
code is set up now, the set of items in the menu is calculated in one
fell swoop, not on a piece-by-piece basis. Therefore reloading the
entire menu on every validateMenuItem call is mondo-overkill.
Is there a better choice? I guess the workaround is to throttle
validateMenuItem by only doing any work when it's a well-known (say,
the first) menu item in the menu. What about the possible scenario of
a menu that has no items at the moment but is being "updated" to
contain items? In this scenario there are no items to receive the
fortuitous validateMenuItem call.
I am trying to avoid using the unsupported NSMenuExtra stuff, but damn
it sure would be easier for some things (like this). I noticed through
some class-dumping and gdb work that NSMenuExtra implementations are
asked for their menu each time the user clicks their part of the menu
bar. This means they automatically get an opportunity to
update/rebuild any menu they might display. It would be nice if
NSStatusItems had the same opportunity...
Daniel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.