NSStatusItem (cocoa) location on screen?

Don't do this by simulating a mouse event, that is completely the wrong way to go. You can use the -popUpStatusItemMenu: method of NSStatusItem to show the menu. You can call this method from a hot key by using a CGEventTap to capture global events that your NSStatusItem can respond to.

On 10.6 you can use the +addGlobalMonitorForEventsMatchingMask:handler: method of NSEvent to capture global events instead of using CGEventTap directly.

Thanks for answering, I am using popUpStatusItemMenu: already but the only downside is that it doesn't highlight the nsstatusitem so I was trying to find an alternative. I think I will just have to settle for popUpStatusItemMenu – Craig Nov 10 '09 at 13:41 addGlobalMonitorForEventsMatchingMask:handler: is for monitoring for events, not posting them, which is what he's doing with the event tap in the question's example. Moreover, it's not the easiest way to implement a hotkey; that would be Carbon Event Manager, whose hotkey API is still supported (even in 64-bit).

– Peter Hosey Dec 24 '09 at 11:43.

Thinking out loud you could create your own custom view for the NSStatusItem. Then for example from the AppController: - (void)awakeFromNib { float width = 30.0; float height = NSStatusBar systemStatusBar thickness; NSRect viewFrame = NSMakeRect(0, 0, width, height); statusItem = NSStatusBar systemStatusBar statusItemWithLength:width retain; statusItem setView:MyCustomView alloc initWithFrame:viewFrame controller:self autorelease; And to simulate the highlight you'd send a message to your custom view. Then when drawing MyCustomView: // In MyCustomView.

M - (void)drawRect:(NSRect)rect { if (clicked) { NSColor selectedMenuItemColor set; NSRectFill(rect); } As well as using -popUpStatusItemMenu:.

Don't do this by simulating a mouse event, that is completely the wrong way to go.

Thinking out loud you could create your own custom view for the NSStatusItem. Then for example from the AppController.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions