forked from romgrk/node-gtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.js
50 lines (39 loc) · 917 Bytes
/
entry.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
/*
* entry.js
*/
const gi = require('../lib/')
const Gtk = gi.require('Gtk', '3.0')
const Gdk = gi.require('Gdk')
gi.startLoop()
Gtk.init()
process.on('uncaughtException', (err) => {
console.log('process.uncaughtException', err)
process.exit(1)
})
process.on('exit', (code) => {
console.log('process.exit', code)
})
process.on('SIGINT', () => {
console.log('process.SIGINT')
process.exit(2)
})
// main program window
const window = new Gtk.Window({
type : Gtk.WindowType.TOPLEVEL
})
// where the URL is written and shown
const entry = new Gtk.Entry()
entry.on('key-press-event', (event) => {
console.log(event)
console.log(event.string)
})
// configure main window
window.setDefaultSize(200, 50)
window.setResizable(true)
window.connect('show', () => {
Gtk.main()
})
window.on('destroy', () => Gtk.mainQuit())
window.on('delete-event', () => false)
window.add(entry)
window.showAll()