Skip to content

Node library for creating simple System Tray applications on OSX

License

Notifications You must be signed in to change notification settings

brandonhorst/node-tray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tray

Node library for creating simple System Tray applications in OSX

Currently only working on node 0.10.x. Support for 0.12.x and io.js will come when NodObjC is updated.

##Installation

npm install native-app tray --save

##Usage

tray relies upon native-app. You must call createApp and pass the app instance to createTray.

var createApp = require('native-app')
var createTray = require('tray')

createApp(function (err, app) {
  createTray(app, function (err, tray) {
    tray.specify({
      title: 'Hello, world!',
      menuItems: [
        {title: 'Informational'},
        {
          title: 'Do something',
          shortcut: 'x',
          action: function () { console.log('You pressed a menuItem!') }
        }
      ]
    })
  })
})

##API Reference

createTray(app, callback)

callback is passed a Tray once it is ready to use.

Each program should only call createTray once. If you want multiple Items in your Tray, simply pass an array to Tray.specify.

Tray

specify(options)

options is an object containing these properties:

  • title: String - Text displayed in the Tray (required)
  • menuItems: [MenuItem] - Items to display in the menu. Each MenuItem is an object containing these properties:
    • title: String - Text displayed for the menuItem (required)
    • action: Function(data) - called when the menuItem is selected. Passed data if it is provided.
    • data - arbitrary data passed to action when it is invoked
    • shortcut: String - Keyboard shortcut that can be pressed when the menu is open. Currently, it must be a single symbol, which is invoked with the cmd modifier. Capitals are OK. For example, k becomes cmd-k and P becomes cmd-shift-p.

close()

Closes the Tray, releasing all memory and removing all items. Any further calls to this Tray will throw.

##Roadmap

  • Tray icons or styled text in Tray (currently only supports plain text)
  • Nested menuItems
  • Separators
  • State (checkmarks on menuItems)
  • Keyboard Alternates (different options when holding alt)
  • Indentation Level
  • Fancy keyboard shortcuts (support shift-cmd-ctrl-alt-y)
  • Images in menuItems
  • Test for memory leaks
  • API for changing existing Tray Items (rather than re-creating every time, for performance)
  • Global activation keyboard shortcut (this is non-trivial)

About

Node library for creating simple System Tray applications on OSX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published