Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create window-like menu on OS X

I'd like to create a same sort of tray menu like this application. Because it is on the list of applications that use node-webkit/nw.js, I think it's possible. I have looked through all the documentation and couldn't find anything on how to achieve that. Searching Google also wasn't really fruitful.

Maybe one of you guys has done this before and could send me in the right direction?

like image 946
Feanaro Avatar asked Feb 27 '15 15:02

Feanaro


People also ask

Can you make Mac work like Windows?

With Boot Camp, you can install and use Windows on your Intel-based Mac. Boot Camp Assistant helps you set up a Windows partition on your Mac computer's hard disk and then start the installation of your Windows software.

What is the Mac equivalent of the Start menu?

Even though you'll miss the Start button, OS X at least has the equivalent of the taskbar called the Dock. It shows you currently open programs and you can add or remove icons for any other applications installed on your Mac.

Is the OS X equivalent of the Windows Control Panel?

A Mac's Control Panel Is System Preferences While Windows calls its configuration options “settings,” macOS usually calls them “preferences.” Before you change any preferences, you'll have to launch the System Preferences app.


1 Answers

First you need to prevent app appear in taskbar

{
    "name": "My App",
    "version": "1.0.0",
    "main": "app.html",
    "window": {
        "show": false,
        "show_in_taskbar": false
    }
}

Then you need to create tray (top bar) menu: (example from his source)

tray = new app.node.gui.Tray({
    title: '',
    icon: 'assets/css/images/menu_icon.png',
    alticon: 'assets/css/images/menu_alticon.png',
    iconsAreTemplates: false
});

Then need create hidden window and show it on click in tray:

// create window
var params = {toolbar: app.devMode, frame: false, transparent: true, resizable: false, show: false};
window = app.node.gui.Window.open('templates/panel.html', params);

function showPopup (x, y) {
  window.on('document-end', function()
    window.moveTo(x - (window.window.width / 2) - 6, y);
    window.show();
    window.focus();
  });
}

// show panel when click in tray
tray.on('click', function (evt) {
  showPopup(evt.x, evt.y);
});
like image 165
Pavel Evstigneev Avatar answered Sep 26 '22 09:09

Pavel Evstigneev