Skip to content

Commit

Permalink
Highlight status item button when it's clicked
Browse files Browse the repository at this point in the history
Fixes (#146)
  • Loading branch information
p0deje committed Aug 11, 2020
1 parent 4e2c1a8 commit 71566fd
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Maccy/Maccy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,28 @@ class Maccy: NSObject {
@objc
func popUpStatusItem() {
withFocus {
self.statusItem.popUpMenu(self.menu)
if let buttonCell = self.statusItem.button?.cell as? NSButtonCell {
buttonCell.highlightsBy = [.changeBackgroundCellMask, .changeGrayCellMask, .contentsCellMask, .pushInCellMask]
self.statusItem.menu = self.menu
self.statusItem.button?.performClick(self)
self.statusItem.menu = nil
buttonCell.highlightsBy = []
}
}
}

private func start() {
statusItem.button?.image = NSImage(named: "StatusBarMenuImage")
statusItem.button?.appearsDisabled = UserDefaults.standard.ignoreEvents
statusItem.behavior = .removalAllowed
statusItem.isVisible = UserDefaults.standard.showInStatusBar
// Simulate statusItem.menu but allowing to withFocus
statusItem.button?.target = self
statusItem.button?.action = #selector(popUpStatusItem)

if let button = statusItem.button {
button.image = NSImage(named: "StatusBarMenuImage")
button.appearsDisabled = UserDefaults.standard.ignoreEvents
// Simulate statusItem.menu but allowing to use withFocus
button.action = #selector(popUpStatusItem)
button.target = self
(button.cell as? NSButtonCell)?.highlightsBy = []
}

clipboard.onNewCopy(history.add)
clipboard.onNewCopy(menu.add)
Expand Down

0 comments on commit 71566fd

Please sign in to comment.