mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
#106 Add IS UNSELECT ON RESELECT style for Input component
This commit is contained in:
parent
23c0853d0a
commit
86c7170053
@ -83,6 +83,7 @@ end
|
|||||||
-- @table style
|
-- @table style
|
||||||
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
|
-- @tfield[opt=false] bool IS_LONGTAP_ERASE Is long tap will erase current input data
|
||||||
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
|
-- @tfield[opt=*] string MASK_DEFAULT_CHAR Default character mask for password input
|
||||||
|
-- @tfield[opt=false] bool IS_UNSELECT_ON_RESELECT If true, call unselect on select selected input
|
||||||
-- @tfield function on_select (self, button_node) Callback on input field selecting
|
-- @tfield function on_select (self, button_node) Callback on input field selecting
|
||||||
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
||||||
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
||||||
@ -92,6 +93,7 @@ function Input.on_style_change(self, style)
|
|||||||
|
|
||||||
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
||||||
self.style.MASK_DEFAULT_CHAR = style.MASK_DEFAULT_CHAR or "*"
|
self.style.MASK_DEFAULT_CHAR = style.MASK_DEFAULT_CHAR or "*"
|
||||||
|
self.style.IS_UNSELECT_ON_RESELECT = style.IS_UNSELECT_ON_RESELECT or false
|
||||||
|
|
||||||
self.style.on_select = style.on_select or function(_, button_node) end
|
self.style.on_select = style.on_select or function(_, button_node) end
|
||||||
self.style.on_unselect = style.on_unselect or function(_, button_node) end
|
self.style.on_unselect = style.on_unselect or function(_, button_node) end
|
||||||
@ -278,6 +280,10 @@ function Input.select(self)
|
|||||||
self.on_input_select:trigger(self:get_context())
|
self.on_input_select:trigger(self:get_context())
|
||||||
|
|
||||||
self.style.on_select(self, self.button.node)
|
self.style.on_select(self, self.button.node)
|
||||||
|
else
|
||||||
|
if self.style.IS_UNSELECT_ON_RESELECT then
|
||||||
|
self:unselect(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,8 +95,9 @@ M["swipe"] = {
|
|||||||
|
|
||||||
M["input"] = {
|
M["input"] = {
|
||||||
IS_LONGTAP_ERASE = true,
|
IS_LONGTAP_ERASE = true,
|
||||||
BUTTON_SELECT_INCREASE = 1.1,
|
BUTTON_SELECT_INCREASE = 1.06,
|
||||||
MASK_DEFAULT_CHAR = "*",
|
MASK_DEFAULT_CHAR = "*",
|
||||||
|
IS_UNSELECT_ON_RESELECT = false,
|
||||||
|
|
||||||
on_select = function(self, button_node)
|
on_select = function(self, button_node)
|
||||||
local target_scale = self.button.start_scale
|
local target_scale = self.button.start_scale
|
||||||
|
Loading…
x
Reference in New Issue
Block a user