Made statusItem imagePosition update based on if title and/or icon exists on mac

This commit is contained in:
Aksel Kornesjö
2018-10-16 13:29:12 +02:00
parent f644d12312
commit 6f103f9f13
+15 -1
View File
@@ -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;
}