Repository navigation
Expand file tree
/
Copy pathNew Window.js
More file actions
72 lines (66 loc) · 1.62 KB
/
Copy pathNew Window.js
File metadata and controls
72 lines (66 loc) · 1.62 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* @description Code Snippet: Demonstrating New Window Creation.
* @version 24.0.0
* @copyright LedgerScript (https://ledgerscript.com)
* @license https://github.com/ledgerscript/scripts/blob/main/LICENSE.md
*/
import ui from "ledger:ui";
window.status = "You can test a new window";
ui.window.height(ui.window.height() + 100);
ui.window.centered(true);
ui.window.insert("Button", {
text: "Create & Show a New Window",
pack: { pad: 20 },
onClick: function () {
const newWindow = ui.window.insert("Window", {
text: "Window Title",
size: [250, 150],
sizeMin: [200, 150],
menuItems: [
[
"File",
[
[
"New",
"Ctrl+N",
"^N",
() => {
alert(`"New" clicked`);
},
],
[
"Open...",
"Ctrl+O",
"^O",
() => {
alert(`"Open..." clicked`);
},
],
[],
[
"Exit",
"Ctrl+Q",
"^Q",
function () {
process.exit(0);
},
],
],
],
],
});
newWindow.insert("Label", { text: "New window text", pack: { pad: 20 } });
newWindow.insert("InputLine", {
text: "New window input Line",
pack: { pad: 20, fill: "x" },
});
newWindow.insert("Button", {
text: "Close New Window",
pack: { pad: 20 },
onClick: function () {
newWindow.close();
},
});
newWindow.centered(true);
},
});