-
Notifications
You must be signed in to change notification settings - Fork 19
/
optionpopup.mjs
61 lines (51 loc) · 1.07 KB
/
optionpopup.mjs
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
import { ConsoleManager, Button, ConfirmPopup, OptionPopup } from "../dist/esm/ConsoleGui.mjs"
const opt = {
title: "Popup Test",
layoutOptions: {
type: "single",
},
logLocation: "popup",
enableMouse: true
}
const GUI = new ConsoleManager(opt)
GUI.on("exit", () => {
closeApp()
})
GUI.on("keypressed", (key) => {
switch (key.name) {
case "q":
new ConfirmPopup({
id: "popupQuit",
title: "Are you sure you want to quit?"
}).show().on("confirm", () => closeApp())
break
default:
break
}
})
const closeApp = () => {
console.clear()
process.exit()
}
const style1 = {
borderColor: "green",
color: "green",
}
const btnProps = {
id: "btnOpen",
text: "Open a popup",
x: 10,
y: 15,
style: style1,
}
const button = new Button(btnProps)
button.on("click", () => {
new OptionPopup({
id: "testPopup",
title: "Choose an option",
options: [1, "string", 3],
selected: "",
}).show()
GUI.refresh()
})
GUI.refresh()