Pergunta

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

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top