Skip to content

Instantly share code, notes, and snippets.

@halida
Last active August 29, 2015 13:57
Show Gist options
  • Save halida/9634676 to your computer and use it in GitHub Desktop.
Save halida/9634676 to your computer and use it in GitHub Desktop.
mylib.close_to_tray = ->
gui = require('nw.gui')
win = gui.Window.get()
tray = null
win.on 'close', ->
this.hide()
tray = new gui.Tray({ icon: 'icon.jpg' })
tray.on 'click', ->
win.show()
this.remove()
tray = null
menu = new gui.Menu()
menu.append(new gui.MenuItem(type: 'normal', label: 'Quit', click: gui.App.quit))
tray.menu = menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment