-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttons.lua
More file actions
79 lines (61 loc) · 1.5 KB
/
buttons.lua
File metadata and controls
79 lines (61 loc) · 1.5 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
73
74
75
76
77
78
79
local ui = require('likelihud')
-- See the main.lua to see how the events emitted below are handled.
-- Use "factory" functions to create similar elements
local function MyButton (t)
return
ui.ImageButton {
path = 'images/button.png',
quad = {
layout = {
rows = 3,
columns = 1,
}
},
onClick = function (self)
self:emit { id = 'last.clicked', data = t.text }
end,
inside = {
ui.Label {
text = t.text
}
}
}
end
local buttons = ui.Layout {
rows = 3,
columns = 1,
ui.Block { },
ui.Layout {
rows = 4,
columns = 1,
fill = { x = true, y = false },
spacing = 1,
MyButton {
text = 'Start'
},
MyButton {
text = 'Settings'
},
MyButton {
text = 'Quit'
},
ui.Layout {
columns = 2,
ui.Label {
align = 'right',
text = 'Last clicked: ',
},
ui.Label {
align = 'left',
text = 'Nothing',
on = {
['last.clicked'] = function (self, event)
self.text = event.message
end
},
}
}
},
ui.Block { },
}
return buttons