[feat] VirtualKeyboard cursor navigation (#3290)

Still lacks Japanese due to insufficient knowledge of the language.
This commit is contained in:
Robert
2017-10-10 18:04:51 +02:00
committed by Frans de Jonge
parent aaab777ddb
commit a392fbcca0
9 changed files with 100 additions and 27 deletions

View File

@@ -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())