# Module `Input`

Druid input text component.

Carry on user text input

Example Link

### Info:

- Author: Part of code from Britzl gooey input component

## Functions

get_text(self) | Return current input field text
get_text_selected_replaced(self, text) | Replace selected text with new text
init(self, click_node, text_node, keyboard_type) | The Input constructor
move_selection(self, delta, is_add_to_selection, is_move_to_end) | Change cursor position by delta
reset_changes(self) | Reset current input selection and return previous value
select(self) | Select input field.
select_cursor(self, cursor_index, start_index, end_index) | Set cursor position in input field
set_allowed_characters(self, characters) | Set allowed charaters for input field.
set_max_length(self, max_length) | Set maximum length for input field.
set_text(self, input_text) | Set text for input field
unselect(self) | Remove selection from input.

## Tables

style | Component style params.

## Fields

allowerd_characters | Pattern matching for user input
button | Button component
current_value | Current input value with marked text
cursor_index | The cursor index.
end_index | Theselection end index.
is_empty | Is current input is empty now
is_selected | Is current input selected now
keyboard_type | Gui keyboard type for input field
marked_text_width | Marked text width
marked_value | Marked text for input field.
max_length | Max length for input text
on_input_empty | On input field text change to empty string callback(self, input_text)
on_input_full | On input field text change to max length string callback(self, input_text)
on_input_select | On input field select callback(self, input_instance)
on_input_text | On input field text change callback(self, input_text)
on_input_unselect | On input field unselect callback(self, input_text, input_instance)
on_input_wrong | On trying user input with not allowed character callback(self, params, input_text)
on_select_cursor_change | On cursor position change callback(self, cursor_index, start_index, end_index)
previous_value | Previous input value
start_index | The selection start index.
text | Text component
text_width | Text width
value | Current input value

## Functions

get_text(self)
  Return current input field text

  ### Parameters:

  - self Input Input

  ### Returns:

  string The current input field text
get_text_selected_replaced(self, text)
  Replace selected text with new text

  ### Parameters:

  - self Input Input
  - text string The text to replace selected text

  ### Returns:

  string New input text
init(self, click_node, text_node, keyboard_type)
  The Input constructor

  ### Parameters:

  - self Input Input
  - click_node node Node to enabled input component
  - text_node node or Text Text node what will be changed on user input. You can pass text component instead of text node name Text
  - keyboard_type number or nil Gui keyboard type for input field
move_selection(self, delta, is_add_to_selection, is_move_to_end)
  Change cursor position by delta

  ### Parameters:

  - self Input Input
  - delta number side for cursor position, -1 for left, 1 for right
  - is_add_to_selection boolean (Shift key)
  - is_move_to_end boolean (Ctrl key)
reset_changes(self)
  Reset current input selection and return previous value

  ### Parameters:

  - self Input Input

  ### Returns:

  druid.input Current input instance
select(self)
  Select input field. It will show the keyboard and trigger on_select events

  ### Parameters:

  - self Input Input
select_cursor(self, cursor_index, start_index, end_index)
  Set cursor position in input field

  ### Parameters:

  - self Input Input
  - cursor_index number or nil Cursor index for cursor position, if nil - will be set to the end of the text
  - start_index number or nil Start index for cursor position, if nil - will be set to the end of the text
  - end_index number or nil End index for cursor position, if nil - will be set to the start_index

  ### Returns:

  druid.input Current input instance
set_allowed_characters(self, characters)
  Set allowed charaters for input field. See: https://defold.com/ref/stable/string/ ex: [%a%d] for alpha and numeric

  ### Parameters:

  - self Input Input
  - characters string Regulax exp. for validate user input

  ### Returns:

  druid.input Current input instance
set_max_length(self, max_length)
  Set maximum length for input field. Pass nil to make input field unliminted (by default)

  ### Parameters:

  - self Input Input
  - max_length number Maximum length for input text field

  ### Returns:

  druid.input Current input instance
set_text(self, input_text)
  Set text for input field

  ### Parameters:

  - self Input Input
  - input_text string The string to apply for input field
unselect(self)
  Remove selection from input. It will hide the keyboard and trigger on_unselect events

  ### Parameters:

  - self Input Input

## Tables

style
  Component style params. You can override this component styles params in druid styles table or create your own style

  ### Fields:

  - IS_LONGTAP_ERASE boolean Is long tap will erase current input data. Default: false
  - MASK_DEFAULT_CHAR string Default character mask for password input. Default: *]
  - IS_UNSELECT_ON_RESELECT boolean If true, call unselect on select selected input. Default: false
  - on_select function (self, button_node) Callback on input field selecting
  - on_unselect function (self, button_node) Callback on input field unselecting
  - on_input_wrong function (self, button_node) Callback on wrong user input
  - button_style table Custom button style for input node

## Fields

allowerd_characters
  Pattern matching for user input
  - allowerd_characters string or nil
button
  Button component
  - button Button Button
current_value
  Current input value with marked text
  - current_value string
cursor_index
  The cursor index. The index of letter cursor after. Leftmost cursor - 0
  - cursor_index number
end_index
  Theselection end index. The index of letter cursor before. Rightmost selection - #text
  - end_index number
is_empty
  Is current input is empty now
  - is_empty boolean
is_selected
  Is current input selected now
  - is_selected boolean
keyboard_type
  Gui keyboard type for input field
  - keyboard_type number
marked_text_width
  Marked text width
  - marked_text_width number
marked_value
  Marked text for input field. Info: https://defold.com/manuals/input-key-and-text/#marked-text
  - marked_value string
max_length
  Max length for input text
  - max_length number or nil
on_input_empty
  On input field text change to empty string callback(self, input_text)
  - on_input_empty DruidEvent DruidEvent
on_input_full
  On input field text change to max length string callback(self, input_text)
  - on_input_full DruidEvent DruidEvent
on_input_select
  On input field select callback(self, input_instance)
  - on_input_select DruidEvent DruidEvent
on_input_text
  On input field text change callback(self, input_text)
  - on_input_text DruidEvent DruidEvent
on_input_unselect
  On input field unselect callback(self, input_text, input_instance)
  - on_input_unselect DruidEvent DruidEvent
on_input_wrong
  On trying user input with not allowed character callback(self, params, input_text)
  - on_input_wrong DruidEvent DruidEvent
on_select_cursor_change
  On cursor position change callback(self, cursor_index, start_index, end_index)
  - on_select_cursor_change DruidEvent DruidEvent
previous_value
  Previous input value
  - previous_value string
start_index
  The selection start index. The index of letter cursor after. Leftmost selection - 0
  - start_index number
text
  Text component
  - text Text Text
text_width
  Text width
  - text_width number
value
  Current input value
  - value string

generated by LDoc TESTING Last updated 2015-01-01 12:00:00