mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[feat] VirtualKeyboard cursor navigation (#3290)
Still lacks Japanese due to insufficient knowledge of the language.
This commit is contained in:
@@ -282,6 +282,7 @@ end
|
||||
-- Click event: Move the cursor to a new location with (x, y), in pixels.
|
||||
-- Be aware of virtual line number of the scorllTextWidget.
|
||||
function TextBoxWidget:moveCursor(x, y)
|
||||
if x < 0 or y < 0 then return end
|
||||
if #self.vertical_string_list == 0 then
|
||||
-- if there's no text at all, nothing to do
|
||||
return 1
|
||||
@@ -357,6 +358,26 @@ function TextBoxWidget:getSize()
|
||||
end
|
||||
end
|
||||
|
||||
function TextBoxWidget:moveCursorUp()
|
||||
if self.vertical_string_list and #self.vertical_string_list < 2 then return end
|
||||
local x, y
|
||||
x, y = self:_findCharPos()
|
||||
local charpos = self:moveCursor(x, y - self.line_height_px +1)
|
||||
if charpos then
|
||||
self:moveCursorToCharpos(charpos)
|
||||
end
|
||||
end
|
||||
|
||||
function TextBoxWidget:moveCursorDown()
|
||||
if self.vertical_string_list and #self.vertical_string_list < 2 then return end
|
||||
local x, y
|
||||
x, y = self:_findCharPos()
|
||||
local charpos = self:moveCursor(x, y + self.line_height_px +1)
|
||||
if charpos then
|
||||
self:moveCursorToCharpos(charpos)
|
||||
end
|
||||
end
|
||||
|
||||
function TextBoxWidget:paintTo(bb, x, y)
|
||||
self.dimen.x, self.dimen.y = x, y
|
||||
bb:blitFrom(self._bb, x, y, 0, 0, self.width, self._bb:getHeight())
|
||||
|
||||
Reference in New Issue
Block a user