Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
feat: Remove tray menu since can only left click tray icon so unable …
Browse files Browse the repository at this point in the history
…to toggle window show/hide
  • Loading branch information
ltfschoen committed Feb 23, 2019
1 parent 34ce6c4 commit 3c29239
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 40 deletions.
8 changes: 4 additions & 4 deletions packages/fether-electron/src/main/app/menu/context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ class FetherContextMenu {
this.buildMenuTemplate(this.menuTemplate);
}

getMenu = () => {
return this.builtMenu;
};

setMenuTemplate = menuTemplate => {
this.menuTemplate = menuTemplate;
};

buildMenuTemplate = menuTemplate => {
this.builtMenu = Menu.buildFromTemplate(menuTemplate);
};

getMenu = () => {
return this.builtMenu;
};
}

export default FetherContextMenu;
8 changes: 4 additions & 4 deletions packages/fether-electron/src/main/app/menu/menubar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class FetherMenubarMenu {
this.builtMenu = Menu.buildFromTemplate(menuTemplate);
};

setMenu = customBuiltMenuTemplate => {
Menu.setApplicationMenu(customBuiltMenuTemplate || this.builtMenu);
};

getMenu = () => {
// return Menu.getApplicationMenu();
return this.builtMenu;
};

setMenu = customBuiltMenuTemplate => {
Menu.setApplicationMenu(customBuiltMenuTemplate || this.builtMenu);
};
}

export default FetherMenubarMenu;
34 changes: 2 additions & 32 deletions packages/fether-electron/src/main/app/methods/loadTray.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,14 @@ function loadTray (fetherApp) {
showTrayBalloon(fetherApp);
}

/**
* On macOS we do not need context menu since taskbar menu permanently shown
* If choose to use "tray" context menu on macOS then it exhibits strange behaviour
* and only works when right-click tray toggles Fether window, and single click
* to toggles Fether menu (not the preferred way of the other way around).
* Note that "window" context menu on macOS using right-click has no issues.
*/
if (process.platform !== 'darwin') {
tray.setContextMenu(fetherApp.contextMenu.getMenu());
}

// Right-click event listener does not work on Windows
tray.on('right-click', () => {
pino.info('Detected right-click on tray icon');

if (process.platform !== 'darwin') {
onTrayClick(fetherApp);
}
});

// Single click event listener works on Windows
tray.on('click', () => {
pino.info('Detected single click on tray icon');

// If the user clicks a menu item in the 'Edit' menu tab
// of the Fether taskbar menu or context menu after clicking the system tray icon
// the menu items do not work because the Fether window is blurred,
// so we need to regain focus on the Fether window for them to work
fetherApp.win.focus();

// On macOS we just use single click on tray icon to toggle Fether window.
// and do not use the context menu since the menu is shown in the taskbar.
if (process.platform !== 'darwin') {
tray.popUpContextMenu();
} else {
onTrayClick(fetherApp);
}
onTrayClick(fetherApp);
});

tray.setToolTip(options.tooltip);
tray.setHighlightMode('never');
}
Expand Down

0 comments on commit 3c29239

Please sign in to comment.