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
|
function file_chooser:onPathChanged(path) -- luacheck: ignore
|
||||||
FileManager.instance.path_text:setText(filemanagerutil.abbreviate(path))
|
FileManager.instance.path_text:setText(filemanagerutil.abbreviate(path))
|
||||||
UIManager:setDirty(FileManager.instance, function()
|
UIManager:setDirty(FileManager.instance, function()
|
||||||
return "ui", FileManager.instance.banner.dimen
|
return "ui", FileManager.instance.path_text.dimen
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -364,7 +364,7 @@ end
|
|||||||
function FileManager:goHome()
|
function FileManager:goHome()
|
||||||
local home_dir = G_reader_settings:readSetting("home_dir")
|
local home_dir = G_reader_settings:readSetting("home_dir")
|
||||||
if home_dir then
|
if home_dir then
|
||||||
self:showFiles(home_dir)
|
self.file_chooser:changeToPath(home_dir)
|
||||||
else
|
else
|
||||||
self:setHome()
|
self:setHome()
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
Button with a big icon image! Designed for touch devices.
|
Button with a big icon image! Designed for touch devices.
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
local Device = require("device")
|
||||||
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||||
@ -24,7 +25,8 @@ local IconButton = InputContainer:new{
|
|||||||
padding_right = nil,
|
padding_right = nil,
|
||||||
padding_bottom = nil,
|
padding_bottom = nil,
|
||||||
padding_left = nil,
|
padding_left = nil,
|
||||||
callback = function() end,
|
enabled = true,
|
||||||
|
callback = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
function IconButton:init()
|
function IconButton:init()
|
||||||
@ -69,17 +71,27 @@ function IconButton:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IconButton:initGesListener()
|
function IconButton:initGesListener()
|
||||||
self.ges_events = {
|
if Device:isTouchDevice() then
|
||||||
TapClickButton = {
|
self.ges_events = {
|
||||||
GestureRange:new{
|
TapIconButton = {
|
||||||
ges = "tap",
|
GestureRange:new{
|
||||||
range = self.dimen,
|
ges = "tap",
|
||||||
|
range = self.dimen,
|
||||||
|
},
|
||||||
|
doc = "Tap IconButton",
|
||||||
|
},
|
||||||
|
HoldIconButton = {
|
||||||
|
GestureRange:new{
|
||||||
|
ges = "hold",
|
||||||
|
range = self.dimen,
|
||||||
|
},
|
||||||
|
doc = "Hold IconButton",
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function IconButton:onTapClickButton()
|
function IconButton:onTapIconButton()
|
||||||
UIManager:scheduleIn(0.0, function()
|
UIManager:scheduleIn(0.0, function()
|
||||||
self.image.invert = true
|
self.image.invert = true
|
||||||
UIManager:setDirty(self.show_parent, function()
|
UIManager:setDirty(self.show_parent, function()
|
||||||
@ -97,6 +109,17 @@ function IconButton:onTapClickButton()
|
|||||||
return true
|
return true
|
||||||
end
|
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)
|
function IconButton:onSetDimensions(new_dimen)
|
||||||
self.dimen = new_dimen
|
self.dimen = new_dimen
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user