[Half-Solved] How to update or redraw NSMenuItem while it is
being displayed
Z Rosen
lists at reelintelligence.com
Thu Mar 11 04:34:51 PST 2004
So with the suggestions to resort to Carbon, I was able to get a plain
ol' NSMenuItem to redraw when changed:
[ [ NSNotificationCenter defaultCenter ] addObserver: self
selector: @selector(redrawMenuCarbon:)
name: NSMenuDidChangeItemNotification
object: nil ];
- (void) redrawMenuCarbon:(NSNotification*)notification
{
extern MenuRef _NSGetCarbonMenu(NSMenu *);
OSStatus err = noErr;
err = UpdateInvalidMenuItems (_NSGetCarbonMenu(statusMenu));
if (err != noErr)
NSLog(@" --- ERROR: Carbon Call UpdateInvalidMenuItems: %i", err );
}
The reason I say "plain ol'" is that it does not seem to work quite
right for NSMenuItems with setAttributedTitle. These items are only
updated when the user rolls on/off them.
Does anyone have any ideas on how to get around this apparent bug? Is
there another Carbon call I may be missing?
Thanx a mil for the help
-ZR
More information about the MacOSX-dev
mailing list