views:

22

answers:

1

I'm creating a pop up menu programmatically and updating it with the delegate method menuNeedsUpdate:(NSMenu *) menu and then displaying it using the popUpMenuPositioningItem:nil atLocation:mouseLoc inView:nil method.

It works fine as far as mouse control is concerned. However, when using the keyboard (letters or arrow keys), I've noticed that it calls menuNeedsUpdate: for everything, the root menu and submenus. This is quite inefficient and makes using the menu via the keyboard sluggish.

Why is this happening? Any way to circumvent it or stop it?

+1  A: 

I would try implementing menuHasKeyEquivalent:forEvent:target:action: on your delegate (and always returning NO if you know nothing in the menu has a key equivalent).

Wevah
Brilliant. That solved it. Interesting though, I've placed an NSLog inside the menuHasKeyEquivalent:forEvent:target:action: method for debug purposes to see if it's called. Well, it gets called I suppose since it works fine now (does not populate the entire menu on every keypress), but the NSLog is not coming up for some reason.
the979kid
Weird, but I'm glad it worked!
Wevah