mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
separated dialog.lua into source files for each individual function
This commit is contained in:
45
frontend/ui/button.lua
Normal file
45
frontend/ui/button.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
require "ui/widget"
|
||||
|
||||
--[[
|
||||
a button widget
|
||||
]]
|
||||
Button = WidgetContainer:new{
|
||||
text = nil, -- mandatory
|
||||
preselect = false
|
||||
}
|
||||
|
||||
function Button:init()
|
||||
-- set FrameContainer content
|
||||
self[1] = FrameContainer:new{
|
||||
margin = 0,
|
||||
bordersize = 3,
|
||||
background = 0,
|
||||
radius = 15,
|
||||
padding = 2,
|
||||
|
||||
HorizontalGroup:new{
|
||||
HorizontalSpan:new{ width = 8 },
|
||||
TextWidget:new{
|
||||
text = self.text,
|
||||
face = Font:getFace("cfont", 20)
|
||||
},
|
||||
HorizontalSpan:new{ width = 8 },
|
||||
}
|
||||
}
|
||||
if self.preselect then
|
||||
self[1].color = 15
|
||||
else
|
||||
self[1].color = 5
|
||||
end
|
||||
end
|
||||
|
||||
function Button:onFocus()
|
||||
self[1].color = 15
|
||||
return true
|
||||
end
|
||||
|
||||
function Button:onUnfocus()
|
||||
self[1].color = 5
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user