NSMenuDelegate - menuNeedsUpdate:(NSMenu *): can I get key(s) pressed?
NSMenuDelegate - menuNeedsUpdate:(NSMenu *): can I get key(s) pressed?
- Subject: NSMenuDelegate - menuNeedsUpdate:(NSMenu *): can I get key(s) pressed?
- From: Jim Prouty <email@hidden>
- Date: Mon, 27 Oct 2014 17:14:27 -0700
QUESTION:
Is there code I can write to get the key(s) pressed during NSMenuDelegate's menuNeedsUpdate:nsmenu method?
Not modifiers, which can be directly queried, but key(s).
Specifically, I want to test whether any of the Function keys F1, F2, etc are down, *during* menuNeedsUpdate,
though it would be awesome to know specifically which key(s) are pressed generally.
Maybe there is a menu or menudelegate message that happens before -menuNeedsUpdate that conveys the keys down info?
Or is there a way to do this is with IOKit or IOHIDManager?
BACKGROUND:
The reason for this question is speed: menuNeedsUpdate is called for *every* keydown. Updating our large number of menus take a while, which slows down normal typing.
If we limit key equivalents to keys with, say, the command modifier required OR function keys with or without modifiers, then typing is fast for normal keys.
Our NSMenuDelegate purposefully does not implement
- (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id *)target action:(SEL *)action
so that -menuNeedsUpdate *is* called.
This way we can update menus before key equivalents are validated.
We're trying to re-implement Carbon's "enable/setup menus just before key equivalents are processed" behavior which worked so well for us (since OS 7) using WaitNextEvent(), but using Cocoa.
I wouldn't care if the solution required OS X 10.10.99.
--Jim
===============================================
Jim Prouty
Voice: (503) 620-3001, FAX: (503) 620-6754
Makers of IGOR Pro, scientific data analysis and graphing for Mac and PC
http://www.wavemetrics.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden