InputText: Delete all and fix Select (#11182)

reviewable/pr11206/r1
hius07 6 months ago committed by GitHub
parent b361cec4ff
commit 498193c26d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -175,14 +175,14 @@ local function initTouchEvents()
}) })
self.selection_start_pos = nil self.selection_start_pos = nil
self.do_select = false self.do_select = false
return true
else -- select start else -- select start
self.selection_start_pos = self.charpos self.selection_start_pos = self.charpos
UIManager:show(Notification:new{ UIManager:show(Notification:new{
text = _("Set cursor to end of selection, then hold."), text = _("Set cursor to end of selection, then long-press in text box."),
}) })
return true
end end
self._hold_handled = true
return true
end end
local clipboard_value = Device.input.getClipboardText() local clipboard_value = Device.input.getClipboardText()
local is_clipboard_empty = clipboard_value == "" local is_clipboard_empty = clipboard_value == ""
@ -233,9 +233,11 @@ local function initTouchEvents()
}, },
{ {
{ {
text = _("Cancel"), text = _("Delete all"),
enabled = #self.charlist > 0,
callback = function() callback = function()
UIManager:close(clipboard_dialog) UIManager:close(clipboard_dialog)
self:delAll()
end, end,
}, },
{ {
@ -243,7 +245,7 @@ local function initTouchEvents()
callback = function() callback = function()
UIManager:close(clipboard_dialog) UIManager:close(clipboard_dialog)
UIManager:show(Notification:new{ UIManager:show(Notification:new{
text = _("Set cursor to start of selection, then hold."), text = _("Set cursor to start of selection, then long-press in text box."),
}) })
self.do_select = true self.do_select = true
end, end,
@ -879,6 +881,15 @@ function InputText:delToStartOfLine()
self:initTextBox(table.concat(self.charlist)) self:initTextBox(table.concat(self.charlist))
end end
function InputText:delAll()
if self.readonly or not self:isTextEditable(true) then
return
end
if #self.charlist == 0 then return end
self.is_text_edited = true
self:initTextBox("")
end
-- For the following cursor/scroll methods, the text_widget deals -- For the following cursor/scroll methods, the text_widget deals
-- itself with setDirty'ing the appropriate regions -- itself with setDirty'ing the appropriate regions
function InputText:leftChar() function InputText:leftChar()

Loading…
Cancel
Save