LoginSignup
5
5

More than 5 years have passed since last update.

OSXでAtom ShellのTray APIを使う時のメモ

Last updated at Posted at 2014-06-18

tray.jpg

でかいアイコン表示するとメニューバーがそれで埋まってしまうw

Windowsはアイコンサイズ調整してくれるのにねぇ

Retina向けのサイズ

正方形だと18x18当たりが狙い目の模様

convert -geometry 18x18 iconOriginalSize.png icon.png 
main.js
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var Menu = require('menu');
var Tray = require('tray');
var appIcon = null;
var contextMenu = null;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
  if (process.platform != 'darwin')
    app.quit();
});
// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
  appIcon = new Tray(__dirname + '/icon.png');
  contextMenu = Menu.buildFromTemplate([{
    label: 'Item1',
    type: 'radio'
  }, {
    label: 'Item2',
    type: 'radio'
  }, {
    label: 'Item3',
    type: 'radio',
    checked: true
  }, {
    label: 'Item4',
    type: 'radio'
  }, ]);
  appIcon.setToolTip('This is my application.');
  appIcon.setContextMenu(contextMenu);

  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600
  });
  // and load the index.html of the app.
  mainWindow.loadUrl('about://blank');
  mainWindow.openDevTools();

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});


関連記事

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5