-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
63 lines (58 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Create a tray icon
let tray = new nw.Tray({
title: 'Tray',
tooltip: 'Tray App is running',
icon: 'assets/icon.png'
});
// Give it a menu
let menu = new nw.Menu();
let itemChecked = true;
// Create an array of the items to be placed in the menu
let menuItems = [
{
type: 'checkbox',
label: 'Checkbox',
checked: itemChecked,
click: function () {
itemChecked = !itemChecked;
console.log(itemChecked);
}
},
{
type: 'normal',
label: 'Open Dev Tools',
click: function () {
nw.Window.get().showDevTools();
}
},
{
type: 'normal',
label: 'Show Window',
click: function () {
nw.Window.get().show();
}
},
{
type: 'normal',
label: 'Hide Window',
click: function () {
nw.Window.get().hide();
}
},
{
type: 'separator'
},
{
type: 'normal',
label: 'Exit',
click: function () {
nw.Window.get().close();
}
}
];
// Append all menu items to the menu
menuItems.forEach(function (item) {
menu.append(new nw.MenuItem(item));
});
// Place the menu in the tray
tray.menu = menu;