-
Notifications
You must be signed in to change notification settings - Fork 0
/
button_demo.lua
45 lines (41 loc) · 1023 Bytes
/
button_demo.lua
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
local uis = require("graphics")
local clicked = 0
function main()
local t = uis.createText()
uis.setProp(t,"parent",term.current())
uis.setProp(t,"size",{
scaleX = 0.25,
scaleY = 0.5,
offX = 0,
offY = 0
})
uis.setProp(t,"pos",{
scaleX = 0.5,
scaleY = 0.25,
offX = 0,
offY = 0
})
uis.setProp(t,"bg",colors.green)
uis.setProp(t,"text","Clicked: "..clicked)
local b = uis.createButton()
uis.setProp(b,"parent",term.current())
uis.setProp(b,"text","Click me!")
uis.setProp(b,"size",{
scaleX = 0.25,
scaleY = 0.5,
offX = 0,
offY = 0
})
uis.setProp(b,"pos",{
scaleX = 0.25,
scaleY = 0.25,
offX = 0,
offY = 0
})
uis.setProp(b,"bg",colors.blue)
uis.setProp(b,"activation", function ()
clicked = clicked + 1
uis.setProp(t,"text","Clicked: "..clicked)
end)
end
parallel.waitForAll(uis.buttonHandler,uis.main,main)