-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathapplication-events.mjs
More file actions
50 lines (42 loc) · 1 KB
/
Copy pathapplication-events.mjs
File metadata and controls
50 lines (42 loc) · 1 KB
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
import { Application } from '../index.js';
const app = new Application();
const window = app.createBrowserWindow({
title: 'Application and window events',
width: 900,
height: 600,
});
const _webview = window.createWebview({
html: `
<main>
<h1>Application and window events</h1>
<p>Move, resize, focus, type, or drop a file onto this window.</p>
<input autofocus placeholder="Type to emit keyboard and IME events">
</main>
`,
});
const eventNames = [
'move',
'resize',
'focus',
'blur',
'key-down',
'key-up',
'file-drop',
'scale-factor-changed',
'theme-changed',
'ime',
'touch',
];
for (const name of eventNames) {
window.on(name, (event) => console.log(name, event));
}
app.on('window-close-requested', (event) => {
console.log('window close requested', event);
});
app.on('custom-menu-click', ({ customMenuEvent }) => {
console.log('custom menu clicked', customMenuEvent);
});
app.on('application-close-requested', () => {
app.exit();
});
app.run();