mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
InputDialog: add param to setInputText() to set cursor pos
When not provided, the cursor stays at its initial position, which might not be the best if replacing the whole content, where we would prefer to have it at start or end.
This commit is contained in:
@@ -500,11 +500,18 @@ function InputDialog:getInputValue()
|
||||
end
|
||||
end
|
||||
|
||||
function InputDialog:setInputText(text, edited_state)
|
||||
function InputDialog:setInputText(text, edited_state, cursor_at_start_or_end)
|
||||
self._input_widget:setText(text)
|
||||
if edited_state ~= nil and self._buttons_edit_callback then
|
||||
self._buttons_edit_callback(edited_state)
|
||||
end
|
||||
if cursor_at_start_or_end ~= nil then -- true=start, false=end
|
||||
if cursor_at_start_or_end then
|
||||
self._input_widget:scrollToTop()
|
||||
else
|
||||
self._input_widget:scrollToBottom()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function InputDialog:isTextEditable()
|
||||
|
||||
Reference in New Issue
Block a user