VirtualKeyboard: hold left/right arrows moves to start/end of line (#7730)

reviewable/pr7709/r1
hius07 3 years ago committed by GitHub
parent dac6fb4008
commit 7419820c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -755,6 +755,18 @@ function InputText:rightChar()
self.charpos, self.top_line_num = self.text_widget:getCharPos()
end
function InputText:goToStartOfLine()
local new_pos = select(1, self:getStringPos({"\n", "\r"}, {"\n", "\r"}))
self.text_widget:moveCursorToCharPos(new_pos)
self.charpos, self.top_line_num = self.text_widget:getCharPos()
end
function InputText:goToEndOfLine()
local new_pos = select(2, self:getStringPos({"\n", "\r"}, {"\n", "\r"})) + 1
self.text_widget:moveCursorToCharPos(new_pos)
self.charpos, self.top_line_num = self.text_widget:getCharPos()
end
function InputText:goToHome()
self.text_widget:moveCursorToCharPos(1)
end

@ -113,8 +113,16 @@ function VirtualKey:init()
--self.skiphold = true
elseif self.label =="" then
self.callback = function() self.keyboard:leftChar() end
self.hold_callback = function()
self.ignore_key_release = true
self.keyboard:goToStartOfLine()
end
elseif self.label == "" then
self.callback = function() self.keyboard:rightChar() end
self.hold_callback = function()
self.ignore_key_release = true
self.keyboard:goToEndOfLine()
end
elseif self.label == "" then
self.callback = function() self.keyboard:upLine() end
elseif self.label == "" then
@ -899,6 +907,14 @@ function VirtualKeyboard:rightChar()
self.inputbox:rightChar()
end
function VirtualKeyboard:goToStartOfLine()
self.inputbox:goToStartOfLine()
end
function VirtualKeyboard:goToEndOfLine()
self.inputbox:goToEndOfLine()
end
function VirtualKeyboard:upLine()
self.inputbox:upLine()
end

Loading…
Cancel
Save