From 2ea5521940fac496c53dcc9f0bac5535326e8b60 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 3 Mar 2022 14:52:45 -0800 Subject: [PATCH] fix: macOS tray icon alternate images (#33105) Co-authored-by: Shelley Vohr --- shell/browser/ui/tray_icon_cocoa.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 382ed5df7c97f..0a37e4fea727e 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -93,6 +93,15 @@ - (void)setImage:(NSImage*)image { - (void)setAlternateImage:(NSImage*)image { [[statusItem_ button] setAlternateImage:image]; + + // We need to change the button type here because the default button type for + // NSStatusItem, NSStatusBarButton, does not display alternate content when + // clicked. NSButtonTypeMomentaryChange displays its alternate content when + // clicked and returns to its normal content when the user releases it, which + // is the behavior users would expect when clicking a button with an alternate + // image set. + [[statusItem_ button] setButtonType:NSButtonTypeMomentaryChange]; + [self updateDimensions]; } - (void)setIgnoreDoubleClickEvents:(BOOL)ignore {