I have a status menu with a NSSearchField and menu items.开发者_如何学编程 When search field is active and user presses up & down arrows, I'd like to start menu tracking, that is that the user will be able to move with arrow keys between menu items. I can catch moveUp and moveDown selectors. How can I cause the menu to become a key responder?
Thanks,
Nava
Fire a kCGEventMouseMoved event on mouseUp/Down. Show/hide cursor on your choice... The main challenge here is find the right origin (global mouse point). Someone has an idea how to find a NSMenuItem rect?
CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, NSPointToCGPoint(globalOrigin) , kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, mouseEvent);
CFRelease(mouseEvent);
精彩评论