mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
confirm and cancel gestures in cropping dialog are replaced by OK/Cancel buttons
Now only "tap" and "pan" gestures are allowed in cropping dialog.
This commit is contained in:
@@ -3,27 +3,37 @@ require "ui/widget"
|
||||
--[[
|
||||
a button widget
|
||||
]]
|
||||
Button = WidgetContainer:new{
|
||||
Button = InputContainer:new{
|
||||
text = nil, -- mandatory
|
||||
preselect = false
|
||||
preselect = false,
|
||||
callback = nil,
|
||||
margin = 0,
|
||||
bordersize = 3,
|
||||
background = 0,
|
||||
radius = 15,
|
||||
padding = 2,
|
||||
width = nil,
|
||||
text_font_face = "cfont",
|
||||
text_font_size = 20,
|
||||
}
|
||||
|
||||
function Button:init()
|
||||
local text_widget = TextWidget:new{
|
||||
text = self.text,
|
||||
face = Font:getFace(self.text_font_face, self.text_font_size)
|
||||
}
|
||||
local text_size = text_widget:getSize()
|
||||
-- set FrameContainer content
|
||||
self[1] = FrameContainer:new{
|
||||
margin = 0,
|
||||
bordersize = 3,
|
||||
background = 0,
|
||||
radius = 15,
|
||||
padding = 2,
|
||||
|
||||
margin = self.margin,
|
||||
bordersize = self.bordersize,
|
||||
background = self.background,
|
||||
radius = self.radius,
|
||||
padding = self.padding,
|
||||
HorizontalGroup:new{
|
||||
HorizontalSpan:new{ width = 8 },
|
||||
TextWidget:new{
|
||||
text = self.text,
|
||||
face = Font:getFace("cfont", 20)
|
||||
},
|
||||
HorizontalSpan:new{ width = 8 },
|
||||
HorizontalSpan:new{ width = (self.width - text_size.w)/2 },
|
||||
text_widget,
|
||||
HorizontalSpan:new{ width = (self.width - text_size.w)/2 },
|
||||
}
|
||||
}
|
||||
if self.preselect then
|
||||
@@ -31,6 +41,18 @@ function Button:init()
|
||||
else
|
||||
self[1].color = 5
|
||||
end
|
||||
self.dimen = self[1]:getSize()
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
TapSelect = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = self.dimen,
|
||||
},
|
||||
doc = "Tap Button",
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Button:onFocus()
|
||||
@@ -43,3 +65,7 @@ function Button:onUnfocus()
|
||||
return true
|
||||
end
|
||||
|
||||
function Button:onTapSelect()
|
||||
self.callback()
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user