mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add on_input_wrong, add allowerd_characters, add simple wrong animation
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
-- @tfield node node Trigger node
|
||||
-- @tfield[opt=node] node anim_node Animation node
|
||||
-- @tfield vector3 start_scale Initial scale of anim_node
|
||||
-- @tfield vector3 start_pos Initial pos of anim_node
|
||||
-- @tfield vector3 pos Initial pos of anim_node
|
||||
-- @tfield any params Params to click callbacks
|
||||
-- @tfield druid.hover hover Druid hover logic component
|
||||
@@ -152,6 +153,7 @@ function M.init(self, node, callback, params, anim_node)
|
||||
|
||||
self.anim_node = anim_node and helper:get_node(anim_node) or self.node
|
||||
self.start_scale = gui.get_scale(self.anim_node)
|
||||
self.start_pos = gui.get_position(self.anim_node)
|
||||
self.params = params
|
||||
self.hover = self.druid:new_hover(node, on_button_hover)
|
||||
self.click_zone = nil
|
||||
|
@@ -20,7 +20,7 @@ local function select(self)
|
||||
self.on_input_select:trigger(self:get_context())
|
||||
|
||||
if self.style.on_select then
|
||||
self.style.on_select(self)
|
||||
self.style.on_select(self, self.button.node)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -35,7 +35,7 @@ local function unselect(self)
|
||||
self.on_input_unselect:trigger(self:get_context())
|
||||
|
||||
if self.style.on_unselect then
|
||||
self.style.on_unselect(self)
|
||||
self.style.on_unselect(self, self.button.node)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -62,7 +62,7 @@ function M.init(self, click_node, text_node, keyboard_type)
|
||||
self.market_text_width = 0
|
||||
self.total_width = 0
|
||||
|
||||
self.max_length = 18
|
||||
self.max_length = nil
|
||||
self.allowed_characters = nil
|
||||
|
||||
self.keyboard_type = keyboard_type or gui.KEYBOARD_TYPE_NUMBER_PAD
|
||||
@@ -77,6 +77,7 @@ function M.init(self, click_node, text_node, keyboard_type)
|
||||
self.on_input_text = Event()
|
||||
self.on_input_empty = Event()
|
||||
self.on_input_full = Event()
|
||||
self.on_input_wrong = Event()
|
||||
end
|
||||
|
||||
|
||||
@@ -100,6 +101,11 @@ function M.on_input(self, action_id, action)
|
||||
if self.max_length then
|
||||
input_text = utf8.sub(input_text, 1, self.max_length)
|
||||
end
|
||||
else
|
||||
self.on_input_wrong:trigger(self:get_context(), action.text)
|
||||
if self.style.on_input_wrong then
|
||||
self.style.on_input_wrong(self, self.button.node)
|
||||
end
|
||||
end
|
||||
self.marked_value = ""
|
||||
end
|
||||
@@ -186,4 +192,15 @@ function M.get_text(self)
|
||||
end
|
||||
|
||||
|
||||
function M.set_max_length(self, max_length)
|
||||
self.max_length = max_length
|
||||
end
|
||||
|
||||
|
||||
-- [%a%d] for alpha numeric
|
||||
function M.set_allowed_characters(self, characters)
|
||||
self.allowed_characters = characters
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user