Skip to content

Commit fbefe51

Browse files
committed
Merge pull request nwjs#2839 from mrfabbri/fix-tray-icon-title-osx
Fix tray title/tooltip issues on Mac OS X
2 parents bf647ba + 09b9e73 commit fbefe51

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/api/tray/tray.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Tray::Tray(int id,
5151

5252
std::string tooltip;
5353
if (option.GetString("tooltip", &tooltip))
54-
SetTitle(tooltip);
54+
SetTooltip(tooltip);
5555

5656
int menu_id;
5757
if (option.GetInteger("menu", &menu_id))

src/api/tray/tray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Tray : public Base {
6464
void Destroy();
6565
void SetTitle(const std::string& title);
6666
void SetIcon(const std::string& icon_path);
67-
void SetTooltip(const std::string& title);
67+
void SetTooltip(const std::string& tooltip);
6868
void SetMenu(Menu* menu);
6969
void Remove();
7070
// Alternate icons only work with Macs

src/api/tray/tray_mac.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ - (void)onClick:(id)sender {
7575
}
7676

7777
void Tray::SetTitle(const std::string& title) {
78+
// note: this is kind of mad but the first time we set the title property
79+
// we have to call setTitle twice or it won't get the right dimensions
80+
if ([status_item_ title] != nil) {
81+
[status_item_ setTitle:[NSString stringWithUTF8String:title.c_str()]];
82+
}
7883
[status_item_ setTitle:[NSString stringWithUTF8String:title.c_str()]];
7984
}
8085

0 commit comments

Comments
 (0)