buttons.lua
local ui = require('likelihud')
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,
tooltip = t.tooltip,
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 = 5,
MyButton {
text = 'Start',
tooltip = {
text = 'Start the game',
}
},
MyButton {
text = 'Settings',
tooltip = {
text = 'Open settings',
}
},
MyButton {
text = 'Quit',
tooltip = {
text = 'Quit the game',
}
},
ui.Layout {
columns = 2,
ui.Label {
align = 'right',
text = 'Last clicked: ',
},
ui.Layout {
rows = 1,
columns = 2,
ui.Label {
align = 'left',
text = 'Nothing',
fill = { x = false, y = true },
elide = true,
on = {
['last.clicked'] = function (self, event)
self:setText(event.message)
end
},
},
ui.Label {
text = '(?)',
align = 'left',
fill = { x = false, y = true },
mouse = {},
tooltip = {
text = 'This is a tooltip',
},
}
}
}
},
ui.Block { },
}
return buttons