From f644d12312f2231d4677f8382407f81c2880803c Mon Sep 17 00:00:00 2001 From: jefvel Date: Tue, 16 Oct 2018 10:29:20 +0200 Subject: Fixed Mac deprecations. Icon is placed correctly. --- systray_darwin.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/systray_darwin.m b/systray_darwin.m index a489bc4..3e5e2ff 100644 --- a/systray_darwin.m +++ b/systray_darwin.m @@ -64,15 +64,16 @@ } - (void)setIcon:(NSImage *)image { - [statusItem setImage:image]; + statusItem.button.image = image; + statusItem.button.imagePosition = NSImageLeft; } - (void)setTitle:(NSString *)title { - [statusItem setTitle:title]; + statusItem.button.title = title; } - (void)setTooltip:(NSString *)tooltip { - [statusItem setToolTip:tooltip]; + statusItem.button.toolTip = tooltip; } - (IBAction)menuHandler:(id)sender @@ -97,14 +98,14 @@ } [menuItem setToolTip:item->tooltip]; if (item->disabled == 1) { - [menuItem setEnabled:FALSE]; + menuItem.enabled = FALSE; } else { - [menuItem setEnabled:TRUE]; + menuItem.enabled = TRUE; } if (item->checked == 1) { - [menuItem setState:NSOnState]; + menuItem.state = NSControlStateValueOn; } else { - [menuItem setState:NSOffState]; + menuItem.state = NSControlStateValueOff; } } -- cgit v1.2.3 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