Skip to content

Commit

Permalink
[Close #46] Revert "[Close #27] Keep icon highlight state after click."
Browse files Browse the repository at this point in the history
This reverts commit 5d28894.

The way to keep status item highlighted no longer works on El Capitan. Revert for now. Need a better approach.
  • Loading branch information
xhacker committed Sep 22, 2015
1 parent 4a9a4bf commit 7f7e123
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions quark-shell/QSHAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
NSImage *statusIcon = [NSImage imageNamed:@"StatusIcon"];
[statusIcon setTemplate:YES];
self.statusItem.button.image = statusIcon;

// We can't keep the button highlighted by calling `setHighlighted:` or `highlight:`.
// So we are adding another invisible button as subview to take over the event handler.
// Then we can call `highlight:` in the event handler.
// See: http://stackoverflow.com/questions/26004684/nsstatusbarbutton-keep-highlighted
NSButton *button = [[NSButton alloc] initWithFrame:self.statusItem.button.frame];
button.alphaValue = 0;
NSArray *array = @[self.statusItem.button, button];
self.statusItem.button.superview.subviews = array;

[button sendActionOn:(NSLeftMouseDownMask | NSRightMouseDownMask)];
button.target = self;
button.action = @selector(statusItemClicked);

self.statusItem.button.target = self;
self.statusItem.button.action = @selector(statusItemClicked);
[self.statusItem.button sendActionOn:(NSLeftMouseDownMask | NSRightMouseDownMask)];
}

self.window.level = NSFloatingWindowLevel;
Expand Down Expand Up @@ -147,8 +138,6 @@ - (void)statusItemClicked

- (void)refreshStyle
{
[self.statusItem.button highlight:self.shouldBeVisible];

NSRect itemFrame;

if (IS_PERIOR_TO_10_9) {
Expand Down

0 comments on commit 7f7e123

Please sign in to comment.