From 778671e751b14d3b8f1440b76bf1b65133cb9e41 Mon Sep 17 00:00:00 2001 From: maxsoch Date: Tue, 14 Jul 2026 17:54:40 +0200 Subject: [PATCH] =?UTF-8?q?keep=20the=20Upgrade=20only=E2=80=A6=20submenu?= =?UTF-8?q?=20visible,=20grey=20out=20the=20empty=20kind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It only appeared when both formulae and casks were outdated; with a single kind it vanished entirely. Now it shows whenever anything is outdated, with the empty kind greyed out (autoenablesItems is off — AppKit would otherwise re-enable the items from the responder chain on every menu open). Co-Authored-By: Claude Fable 5 --- BrewBar/BrewBarApp.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/BrewBar/BrewBarApp.swift b/BrewBar/BrewBarApp.swift index 4df8fd1..467a6d4 100644 --- a/BrewBar/BrewBarApp.swift +++ b/BrewBar/BrewBarApp.swift @@ -86,6 +86,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(upgradeAllItem) upgradeOnlyItem = NSMenuItem(title: "🎯 Upgrade only…", action: nil, keyEquivalent: "") let upgradeOnlySubmenu = NSMenu() + // manual isEnabled control below; otherwise AppKit re-enables the + // items from the responder chain every time the menu opens + upgradeOnlySubmenu.autoenablesItems = false upgradeFormulaeItem = NSMenuItem(title: "Formulae", action: #selector(upgradeFormulaeOnly), keyEquivalent: "") upgradeCasksItem = NSMenuItem(title: "Casks", action: #selector(upgradeCasksOnly), keyEquivalent: "") upgradeOnlySubmenu.addItem(upgradeFormulaeItem) @@ -570,11 +573,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { outdatedSubmenu.removeAllItems() outdatedItem.isHidden = outdated.isEmpty upgradeAllItem.isHidden = outdated.isEmpty - // "only" is meaningful only when both kinds are outdated; with a - // single kind, the main item already upgrades exactly what there is - upgradeOnlyItem.isHidden = outdated.formulae.isEmpty || outdated.casks.isEmpty - upgradeFormulaeItem.title = "Formulae (\(outdated.formulae.count))" - upgradeCasksItem.title = "Casks (\(outdated.casks.count))" + // visible whenever anything is outdated; a kind with nothing to + // upgrade stays listed but greyed out + upgradeOnlyItem.isHidden = outdated.isEmpty + upgradeFormulaeItem.title = outdated.formulae.isEmpty ? "Formulae" : "Formulae (\(outdated.formulae.count))" + upgradeFormulaeItem.isEnabled = !outdated.formulae.isEmpty + upgradeCasksItem.title = outdated.casks.isEmpty ? "Casks" : "Casks (\(outdated.casks.count))" + upgradeCasksItem.isEnabled = !outdated.casks.isEmpty for package in outdated.all { let item = NSMenuItem(title: package.label, action: #selector(upgradeSingle(_:)), keyEquivalent: "")