Add esc button to unselect input field

This commit is contained in:
Insality
2020-04-18 02:08:56 +03:00
parent 6d84f06c32
commit 56795363f8
3 changed files with 18 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ local function select(self)
gui.reset_keyboard()
self.marked_value = ""
if not self.selected then
self.previous_value = self.value
self.selected = true
gui.show_keyboard(self.keyboard_type, false)
self.on_input_select:trigger(self:get_context())
@@ -53,6 +54,7 @@ function M.init(self, click_node, text_node, keyboard_type)
self.text = self.druid:new_text(text_node)
self.selected = false
self.previous_value = ""
self.value = ""
self.marked_value = ""
self.current_value = ""
@@ -132,6 +134,11 @@ function M.on_input(self, action_id, action)
return true
end
if action_id == const.ACTION_ESC and action.released then
unselect(self)
return true
end
if input_text then
self:set_text(input_text)
return true
@@ -203,4 +210,10 @@ function M.set_allowed_characters(self, characters)
end
function M.reset_changes(self)
self:set_text(self.previous_value)
unselect(self)
end
return M