Merge pull request #121 from Insality/116-input-component-arg

#116 Add ability to pass text component instead of text node name
This commit is contained in:
Maxim Tuprikov 2021-04-01 20:35:36 +03:00 committed by GitHub
commit eb1b03bd8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -139,4 +139,5 @@ Desc
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
- Add EmmyLua annotations. See how to use it FAQ
- Lang text now can be initialized without default locale id
- **#116** You can pass Text component in Input component instead of text node
- **#124** Add _set_click_zone_ functon to Scroll component (just link to Drag:set_click_zone inside scroll component)

View File

@ -108,11 +108,16 @@ end
-- @tparam node click_node Button node to enabled input component
-- @tparam node text_node Text node what will be changed on user input
-- @tparam node|druid.text text_node Text node what will be changed on user input. You can pass text component instead of text node name
-- @tparam[opt] number keyboard_type Gui keyboard type for input field
function Input.init(self, click_node, text_node, keyboard_type)
self.druid = self:get_druid(self)
self.text = self.druid:new_text(text_node)
if type(text_node) == const.TABLE then
self.text = text_node
else
self.text = self.druid:new_text(text_node)
end
self.is_selected = false
self.value = self.text.last_value