# Defold Druid UI Library

# Module `DruidInstance`

Instance of Druid.

Make one instance per gui_script with next code:

local druid = require("druid.druid") function init(self) self.druid = druid.new(self) local button = self.druid:new_button(...) end

Learn Druid instance function here

### See also:

- Button
- Blocker
- BackHandler
- Input
- Text
- LangText
- Timer
- Progress
- StaticGrid
- DynamicGrid
- Scroll
- Slider
- Checkbox
- CheckboxGroup
- RadioGroup
- Swipe
- Drag
- DataList
- Hover

## Functions

initialize(self, context, style) | Druid class constructor
new(self, component, ...) | Create new druid component
final(self) | Call on final function on gui_script.
remove(self, component) | Remove component from druid instance.
update(self, dt) | Druid update function
on_input(self, action_id, action) | Druid on_input function
on_message(self, message_id, message, sender) | Druid on_message function
on_focus_lost(self) | Druid on focus lost interest function.
on_focus_gained(self) | Druid on focus gained interest function.
on_layout_change(self) | Druid on layout change function.
druid.on_language_change() | Druid on language change.
new_button(self, node, callback[, params[, anim_node]]) | Create button basic component
new_blocker(self, node) | Create blocker basic component
new_back_handler(self, callback[, params]) | Create back_handler basic component
new_hover(self, node, on_hover_callback) | Create hover basic component
new_text(self, node[, value[, no_adjust]]) | Create text basic component
new_grid(self, parent, element[, in_row=1]) | Create grid basic component Deprecated
new_static_grid(self, parent, element[, in_row=1]) | Create static grid basic component
new_scroll(self, view_node, content_node) | Create scroll basic component
new_swipe(self, node, on_swipe_callback) | Create swipe basic component
new_drag(self, node, on_drag_callback) | Create drag basic component
new_dynamic_grid(self, parent) | Create dynamic grid component
new_lang_text(self, node, locale_id, no_adjust) | Create lang_text component
new_slider(self, node, end_pos[, callback]) | Create slider component
new_checkbox(self, node, callback[, click_node=node]) | Create checkbox component
new_input(self, click_node, text_node[, keyboard_type]) | Create input component
new_checkbox_group(self, nodes, callback[, click_nodes=node]) | Create checkbox_group component
druid:new_data_list(druid_scroll, druid_grid, create_function) | Create data list basic component
new_radio_group(self, nodes, callback[, click_nodes=node]) | Create radio_group component
new_timer(self, node, seconds_from[, seconds_to=0[, callback]]) | Create timer component
new_progress(self, node, key[, init_value=1]) | Create progress component

## Functions

initialize(self, context, style)
  Druid class constructor

  ### Parameters:

  - self DruidInstance
  - context table Druid context. Usually it is self of script
  - style table Druid style module
new(self, component, ...)
  Create new druid component

  ### Parameters:

  - self DruidInstance
  - component Component Component module
  - ... args Other component params to pass it to component:init function
final(self)
  Call on final function on gui_script. It will call on_remove on all druid components

  ### Parameters:

  - self DruidInstance
remove(self, component)
  Remove component from druid instance. Component `on_remove` function will be invoked, if exist.

  ### Parameters:

  - self DruidInstance
  - component Component Component instance
update(self, dt)
  Druid update function

  ### Parameters:

  - self DruidInstance
  - dt number Delta time
on_input(self, action_id, action)
  Druid on_input function

  ### Parameters:

  - self DruidInstance
  - action_id hash Action_id from on_input
  - action table Action from on_input
on_message(self, message_id, message, sender)
  Druid on_message function

  ### Parameters:

  - self DruidInstance
  - message_id hash Message_id from on_message
  - message table Message from on_message
  - sender hash Sender from on_message
on_focus_lost(self)
  Druid on focus lost interest function. This one called by on_window_callback by global window listener

  ### Parameters:

  - self DruidInstance
on_focus_gained(self)
  Druid on focus gained interest function. This one called by on_window_callback by global window listener

  ### Parameters:

  - self DruidInstance
on_layout_change(self)
  Druid on layout change function. Called on update gui layout

  ### Parameters:

  - self DruidInstance
druid.on_language_change()
  Druid on language change. This one called by global gruid.on_language_change, but can be call manualy to update all translations
new_button(self, node, callback[, params[, anim_node]])
  Create button basic component

  ### Parameters:

  - self DruidInstance
  - node node Gui node
  - callback function Button callback
  - params table Button callback params (optional)
  - anim_node node Button anim node (node, if not provided) (optional)

  ### Returns:

  Button button component
new_blocker(self, node)
  Create blocker basic component

  ### Parameters:

  - self DruidInstance
  - node node Gui node

  ### Returns:

  Blocker blocker component
new_back_handler(self, callback[, params])
  Create back_handler basic component

  ### Parameters:

  - self DruidInstance
  - callback callback On back button
  - params any Callback argument (optional)

  ### Returns:

  BackHandler back_handler component
new_hover(self, node, on_hover_callback)
  Create hover basic component

  ### Parameters:

  - self DruidInstance
  - node node Gui node
  - on_hover_callback function Hover callback

  ### Returns:

  Hover hover component
new_text(self, node[, value[, no_adjust]])
  Create text basic component

  ### Parameters:

  - self DruidInstance
  - node node Gui text node
  - value string Initial text. Default value is node text from GUI scene. (optional)
  - no_adjust bool If true, text will be not auto-adjust size (optional)

  ### Returns:

  Tet text component
new_grid(self, parent, element[, in_row=1])
  Create grid basic component Deprecated

  ### Parameters:

  - self DruidInstance
  - parent node The gui node parent, where items will be placed
  - element node Element prefab. Need to get it size
  - in_row number How many nodes in row can be placed (default 1)

  ### Returns:

  StaticGrid grid component
new_static_grid(self, parent, element[, in_row=1])
  Create static grid basic component

  ### Parameters:

  - self DruidInstance
  - parent node The gui node parent, where items will be placed
  - element node Element prefab. Need to get it size
  - in_row number How many nodes in row can be placed (default 1)

  ### Returns:

  StaticGrid grid component
new_scroll(self, view_node, content_node)
  Create scroll basic component

  ### Parameters:

  - self DruidInstance
  - view_node node GUI view scroll node
  - content_node node GUI content scroll node

  ### Returns:

  Scroll scroll component
new_swipe(self, node, on_swipe_callback)
  Create swipe basic component

  ### Parameters:

  - self DruidInstance
  - node node Gui node
  - on_swipe_callback function Swipe callback for on_swipe_end event

  ### Returns:

  Swipe swipe component
new_drag(self, node, on_drag_callback)
  Create drag basic component

  ### Parameters:

  - self DruidInstance
  - node node GUI node to detect dragging
  - on_drag_callback function Callback for on_drag_event(self, dx, dy)

  ### Returns:

  Drag drag component
new_dynamic_grid(self, parent)
  Create dynamic grid component

  ### Parameters:

  - self DruidInstance
  - parent node The gui node parent, where items will be placed

  ### Returns:

  DynamicGrid grid component
new_lang_text(self, node, locale_id, no_adjust)
  Create lang_text component

  ### Parameters:

  - self DruidInstance
  - node node The text node
  - locale_id string Default locale id
  - no_adjust bool If true, will not correct text size

  ### Returns:

  LangText lang_text component
new_slider(self, node, end_pos[, callback])
  Create slider component

  ### Parameters:

  - self DruidInstance
  - node node Gui pin node
  - end_pos vector3 The end position of slider
  - callback function On slider change callback (optional)

  ### Returns:

  Slider slider component
new_checkbox(self, node, callback[, click_node=node])
  Create checkbox component

  ### Parameters:

  - self DruidInstance
  - node node Gui node
  - callback function Checkbox callback
  - click_node node Trigger node, by default equals to node (default node)

  ### Returns:

  Checkbox checkbox component
new_input(self, click_node, text_node[, keyboard_type])
  Create input component

  ### Parameters:

  - self DruidInstance
  - click_node node Button node to enabled input component
  - text_node node Text node what will be changed on user input
  - keyboard_type number Gui keyboard type for input field (optional)

  ### Returns:

  Input input component
new_checkbox_group(self, nodes, callback[, click_nodes=node])
  Create checkbox_group component

  ### Parameters:

  - self DruidInstance
  - nodes node[] Array of gui node
  - callback function Checkbox callback
  - click_nodes node[] Array of trigger nodes, by default equals to nodes (default node)

  ### Returns:

  CheckboxGroup checkbox_group component
druid:new_data_list(druid_scroll, druid_grid, create_function)
  Create data list basic component

  ### Parameters:

  - druid_scroll druid.scroll The Scroll instance for Data List component
  - druid_grid druid.grid The Grid instance for Data List component
  - create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])

  ### Returns:

  DataList data_list component
new_radio_group(self, nodes, callback[, click_nodes=node])
  Create radio_group component

  ### Parameters:

  - self DruidInstance
  - nodes node[] Array of gui node
  - callback function Radio callback
  - click_nodes node[] Array of trigger nodes, by default equals to nodes (default node)

  ### Returns:

  RadioGroup radio_group component
new_timer(self, node, seconds_from[, seconds_to=0[, callback]])
  Create timer component

  ### Parameters:

  - self DruidInstance
  - node node Gui text node
  - seconds_from number Start timer value in seconds
  - seconds_to number End timer value in seconds (default 0)
  - callback function Function on timer end (optional)

  ### Returns:

  Timer timer component
new_progress(self, node, key[, init_value=1])
  Create progress component

  ### Parameters:

  - self DruidInstance
  - node string or node Progress bar fill node or node name
  - key string Progress bar direction: const.SIDE.X or const.SIDE.Y
  - init_value number Initial value of progress bar (default 1)

  ### Returns:

  Progress progress component

generated by LDoc 1.4.6 Last updated 2021-04-06 00:03:14