sokoban.love/0124-styled_button

21 lines
591 B
Plaintext

styled_button = function(name, x, y, onpress1)
local w = App.width(name)+10
button(Global_state, name, {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
icon = function(p)
if Active_button and Active_button.name == name and Active_button.expire > Current_time then
App.color(Highlighted_button_color)
else
App.color(Normal_color)
end
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print(name, p.x+5,p.y+2)
end,
onpress1 = function()
onpress1()
Active_button = {
name=name,
expire=Current_time+0.1,
}
end,
})
end