tray
v2.0.1
Published
Node library for creating simple System Tray applications on OSX
Downloads
20
Maintainers
Readme
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. Passeddata
if it is provided.data
- arbitrary data passed toaction
when it is invokedshortcut: String
- Keyboard shortcut that can be pressed when the menu is open. Currently, it must be a single symbol, which is invoked with thecmd
modifier. Capitals are OK. For example,k
becomescmd-k
and P becomescmd-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)