Solve #189 Add temporary set input priority

This commit is contained in:
Insality 2022-06-15 10:34:47 +05:00
parent c9f862ac03
commit 53f305734c
2 changed files with 9 additions and 4 deletions

View File

@ -218,17 +218,22 @@ end
--- Set component input priority --- Set component input priority
-- @tparam BaseComponent self @{BaseComponent} -- @tparam BaseComponent self @{BaseComponent}
-- @tparam number value The new input priority value -- @tparam number value The new input priority value
-- @tparam boolean is_temporary If true, the reset input priority will return to previous value
-- @treturn number The component input priority -- @treturn number The component input priority
function BaseComponent.set_input_priority(self, value) function BaseComponent.set_input_priority(self, value, is_temporary)
assert(value) assert(value)
if self._component.input_priority ~= value then if self._component.input_priority ~= value then
self._component.input_priority = value self._component.input_priority = value
self._component._is_input_priority_changed = true self._component._is_input_priority_changed = true
if not is_temporary then
self._component.default_input_priority = value
end
local children = self:get_childrens() local children = self:get_childrens()
for i = 1, #children do for i = 1, #children do
children[i]:set_input_priority(value) children[i]:set_input_priority(value, is_temporary)
end end
end end

View File

@ -281,8 +281,8 @@ function Input.select(self)
gui.reset_keyboard() gui.reset_keyboard()
self.marked_value = "" self.marked_value = ""
if not self.is_selected then if not self.is_selected then
self:set_input_priority(const.PRIORITY_INPUT_MAX) self:set_input_priority(const.PRIORITY_INPUT_MAX, true)
self.button:set_input_priority(const.PRIORITY_INPUT_MAX) self.button:set_input_priority(const.PRIORITY_INPUT_MAX, true)
self.previous_value = self.value self.previous_value = self.value
self.is_selected = true self.is_selected = true