mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
press Enter in Goto Dialog will goto page/location directly
This commit is contained in:
@@ -25,7 +25,7 @@ function ReaderGoto:onShowGotoDialog()
|
||||
DEBUG("show goto dialog")
|
||||
self.goto_dialog = InputDialog:new{
|
||||
title = self.goto_dialog_title,
|
||||
input_hint = "(1 - "..self.document.info.number_of_pages..")",
|
||||
input_hint = "(1 - "..self.document:getPageCount()..")",
|
||||
buttons = {
|
||||
{
|
||||
{
|
||||
@@ -52,6 +52,9 @@ function ReaderGoto:onShowGotoDialog()
|
||||
},
|
||||
},
|
||||
input_type = "number",
|
||||
enter_callback = self.document.info.has_pages
|
||||
and function() self:gotoPage() end
|
||||
or function() self:gotoLocation() end,
|
||||
width = Screen:getWidth() * 0.8,
|
||||
height = Screen:getHeight() * 0.2,
|
||||
}
|
||||
@@ -74,6 +77,10 @@ function ReaderGoto:gotoPage()
|
||||
end
|
||||
|
||||
function ReaderGoto:gotoLocation()
|
||||
-- TODO: implement go to location
|
||||
local number = tonumber(self.goto_dialog:getInputText())
|
||||
if number then
|
||||
self.ui:handleEvent(Event:new("GotoPage", number))
|
||||
end
|
||||
self:close()
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -7,6 +7,7 @@ InputDialog = InputContainer:new{
|
||||
input_hint = "",
|
||||
buttons = nil,
|
||||
input_type = nil,
|
||||
enter_callback = nil,
|
||||
|
||||
width = nil,
|
||||
height = nil,
|
||||
@@ -38,6 +39,7 @@ function InputDialog:init()
|
||||
face = self.input_face,
|
||||
width = self.width * 0.9,
|
||||
input_type = self.input_type,
|
||||
enter_callback = self.enter_callback,
|
||||
scroll = false,
|
||||
parent = self,
|
||||
}
|
||||
|
||||
@@ -94,6 +94,10 @@ function InputText:getKeyboardDimen()
|
||||
end
|
||||
|
||||
function InputText:addChar(char)
|
||||
if self.enter_callback and char == '\n' then
|
||||
UIManager:scheduleIn(0.1, function() self.enter_callback() end)
|
||||
return
|
||||
end
|
||||
table.insert(self.charlist, self.charpos, char)
|
||||
self.charpos = self.charpos + 1
|
||||
self.text = self:CharlistToString()
|
||||
|
||||
Reference in New Issue
Block a user