mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
[fix] Add hold_callback to IconButton (#3271)
Also fix path display update. Fixes #3270.
This commit is contained in:
parent
5da6624ec6
commit
0d7999e7a5
@ -116,7 +116,7 @@ function FileManager:init()
|
||||
function file_chooser:onPathChanged(path) -- luacheck: ignore
|
||||
FileManager.instance.path_text:setText(filemanagerutil.abbreviate(path))
|
||||
UIManager:setDirty(FileManager.instance, function()
|
||||
return "ui", FileManager.instance.banner.dimen
|
||||
return "ui", FileManager.instance.path_text.dimen
|
||||
end)
|
||||
return true
|
||||
end
|
||||
@ -364,7 +364,7 @@ end
|
||||
function FileManager:goHome()
|
||||
local home_dir = G_reader_settings:readSetting("home_dir")
|
||||
if home_dir then
|
||||
self:showFiles(home_dir)
|
||||
self.file_chooser:changeToPath(home_dir)
|
||||
else
|
||||
self:setHome()
|
||||
end
|
||||
|
@ -2,6 +2,7 @@
|
||||
Button with a big icon image! Designed for touch devices.
|
||||
--]]
|
||||
|
||||
local Device = require("device")
|
||||
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
@ -24,7 +25,8 @@ local IconButton = InputContainer:new{
|
||||
padding_right = nil,
|
||||
padding_bottom = nil,
|
||||
padding_left = nil,
|
||||
callback = function() end,
|
||||
enabled = true,
|
||||
callback = nil,
|
||||
}
|
||||
|
||||
function IconButton:init()
|
||||
@ -69,17 +71,27 @@ function IconButton:update()
|
||||
end
|
||||
|
||||
function IconButton:initGesListener()
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
TapClickButton = {
|
||||
TapIconButton = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = self.dimen,
|
||||
}
|
||||
},
|
||||
doc = "Tap IconButton",
|
||||
},
|
||||
HoldIconButton = {
|
||||
GestureRange:new{
|
||||
ges = "hold",
|
||||
range = self.dimen,
|
||||
},
|
||||
doc = "Hold IconButton",
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function IconButton:onTapClickButton()
|
||||
function IconButton:onTapIconButton()
|
||||
UIManager:scheduleIn(0.0, function()
|
||||
self.image.invert = true
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
@ -97,6 +109,17 @@ function IconButton:onTapClickButton()
|
||||
return true
|
||||
end
|
||||
|
||||
function IconButton:onHoldIconButton()
|
||||
if self.enabled and self.hold_callback then
|
||||
self.hold_callback()
|
||||
elseif self.hold_input then
|
||||
self:onInput(self.hold_input)
|
||||
elseif type(self.hold_input_func) == "function" then
|
||||
self:onInput(self.hold_input_func())
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function IconButton:onSetDimensions(new_dimen)
|
||||
self.dimen = new_dimen
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user