# Module `BaseComponent`

Basic class for all Druid components.

To create you custom component, use static function `component.create`

### Usage:

    -- Create your component:
    local component = require("druid.component")

    local AwesomeComponent = component.create("awesome_component")

    function AwesomeComponent:init(template, nodes)
        self:set_template(template)
        self:set_nodes(nodes)
        self.druid = self:get_druid()
    end

    return AwesomeComponent

## Functions

get_childrens(self) | Return all children components, recursive
get_context(self) | Context used as first arg in all Druid events
get_druid(self) | Get Druid instance for inner component creation.
get_input_priority(self) | Return component input priority
get_name(self) | Return component name
get_node(self, node_or_name) | Get component node by name.
get_parent_component(self) | Return the parent component if exist
get_parent_name(self) | Return parent component name
get_template(self) | Get current component template name.
get_uid(self) | Return component UID.
reset_input_priority(self) | Reset component input priority to default value
set_input_enabled(self, state) | Set component input state.
set_input_priority(self, value, is_temporary) | Set component input priority
set_nodes(self, nodes) | Set current component nodes.
set_style(self, druid_style) | Set current component style table.
set_template(self, template) | Set component template name.

## Functions

get_childrens(self)
  Return all children components, recursive

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  table Array of childrens if the Druid component instance
get_context(self)
  Context used as first arg in all Druid events Context is usually self of gui_script.

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  table BaseComponent context
get_druid(self)
  Get Druid instance for inner component creation.

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  DruidInstance Druid instance with component context
get_input_priority(self)
  Return component input priority

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  number The component input priority
get_name(self)
  Return component name

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  string The component name
get_node(self, node_or_name)
  Get component node by name.

  If component has nodes, node_or_name should be string It autopick node by template name or from nodes by gui.clone_tree if they was setup via component:set_nodes, component:set_template. If node is not found, the exception will fired

  ### Parameters:

  - self BaseComponent BaseComponent
  - node_or_name string or node Node name or node itself

  ### Returns:

  node Gui node
get_parent_component(self)
  Return the parent component if exist

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  BaseComponent or nil The druid component instance or nil
get_parent_name(self)
  Return parent component name

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  string or nil The parent component name if exist or bil
get_template(self)
  Get current component template name.

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  string Component full template name
get_uid(self)
  Return component UID.

  UID generated in component creation order.

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  number The component uid
reset_input_priority(self)
  Reset component input priority to default value

  ### Parameters:

  - self BaseComponent BaseComponent

  ### Returns:

  number The component input priority
set_input_enabled(self, state)
  Set component input state. By default it enabled

  If input is disabled, the component will not receive input events

  ### Parameters:

  - self BaseComponent BaseComponent
  - state boolean or nil The component input state

  ### Returns:

  BaseComponent BaseComponent itself
set_input_priority(self, value, is_temporary)
  Set component input priority Default value: 10

  ### Parameters:

  - self BaseComponent BaseComponent
  - value number The new input priority value
  - is_temporary boolean or nil If true, the reset input priority will return to previous value

  ### Returns:

  number The component input priority
set_nodes(self, nodes)
  Set current component nodes. Use if your component nodes was cloned with `gui.clone_tree` and you got the node tree.

  ### Parameters:

  - self BaseComponent BaseComponent
  - nodes table BaseComponent nodes table

  ### Returns:

  BaseComponent BaseComponent

  ### Usage:

      local nodes = gui.clone_tree(self.prefab)
      ... In your component:
      self:set_nodes(nodes)

set_style(self, druid_style)
  Set current component style table.

  Invoke `on_style_change` on component, if exist. Component should handle their style changing and store all style params

  ### Parameters:

  - self BaseComponent BaseComponent
  - druid_style table or nil Druid style module

  ### Returns:

  BaseComponent BaseComponent
set_template(self, template)
  Set component template name.

  Use on all your custom components with GUI layouts used as templates. It will check parent template name to build full template name in self:get_node()

  ### Parameters:

  - self BaseComponent BaseComponent
  - template string BaseComponent template name

  ### Returns:

  BaseComponent BaseComponent

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