-
Notifications
You must be signed in to change notification settings - Fork 19
/
mouse_test.mjs
58 lines (48 loc) · 1.07 KB
/
mouse_test.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
import { ConsoleManager, Button, ConfirmPopup } from "../dist/esm/ConsoleGui.mjs"
const opt = {
title: "Click the button",
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: "red",
color: "red",
}
const btnProps = {
id: "btnClickMe",
text: "Click Me! (Ctrl+R)",
x: 10,
y: 15,
style: style1,
key: { name: "r", ctrl: true },
}
const button = new Button(btnProps)
button.on("click", () => {
button.absoluteValues.x = Math.floor(Math.random() * 30)
button.absoluteValues.y = Math.floor(Math.random() * 30)
GUI.refresh()
})
GUI.refresh()