From 6f103f9f13a325617926c2e66da5ff3e0700f919 Mon Sep 17 00:00:00 2001 From: Aksel Kornesjö Date: Tue, 16 Oct 2018 13:29:12 +0200 Subject: Made statusItem imagePosition update based on if title and/or icon exists on mac --- systray_darwin.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/systray_darwin.m b/systray_darwin.m index 3e5e2ff..e466948 100644 --- a/systray_darwin.m +++ b/systray_darwin.m @@ -65,13 +65,27 @@ - (void)setIcon:(NSImage *)image { statusItem.button.image = image; - statusItem.button.imagePosition = NSImageLeft; + [self updateTitleButtonStyle]; } - (void)setTitle:(NSString *)title { statusItem.button.title = title; + [self updateTitleButtonStyle]; } +-(void)updateTitleButtonStyle { + if (statusItem.button.image != nil) { + if ([statusItem.button.title length] == 0) { + statusItem.button.imagePosition = NSImageOnly; + } else { + statusItem.button.imagePosition = NSImageLeft; + } + } else { + statusItem.button.imagePosition = NSNoImage; + } +} + + - (void)setTooltip:(NSString *)tooltip { statusItem.button.toolTip = tooltip; } -- cgit v1.2.3