Question

I'd like to perform the following:
when I click on the status bar item (NSStatusItem) I want to highlight it (no menu) indefinitely and when the application loses focus I want to stop highlighting it.

Is there any way of doing this? I can't find it, tbh.

Was it helpful?

Solution

You can probably do this with a custom view that sends the status item a drawStatusBarBackgroundInRect:withHighlight: message.

I doubt there's any way to do it without a custom view, since, as I mentioned in my comment on the question, keeping the item highlighted when the user doesn't have the mouse down on it looks bad.

OTHER TIPS

Old question, but I think it is worth adding this alternative answer.

This will not automatically un-highlight when the application loses focus, but this allows you to highlight without using a custom view (as the other answer requires):

NSStatusItem *statusItem = [self getStatusItem];
[statusItem.button setHighlighted:YES];

You can unhighlight it manually using the same method:

[statusItem.button setHighlighted:NO];

Note I got this answer from a similar question here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top