From 52c45ef6db71849143f06c8fa63bd3a38a9bfe21 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sun, 8 Oct 2023 17:51:35 +0200 Subject: [PATCH] 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. --- frontend/ui/widget/inputdialog.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index 150110ec7..a01be520b 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -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()