at /druid/component.lua
component.create([name], [input_priority])Сreate a new component class, which will inherit from the base Druid component.
-
Parameters:
[name](string|nil): The name of the component[input_priority](number|nil): The input priority. The bigger number processed first. Default value: 10
-
Returns:
- `` (druid.component):
component.create_widget(self, widget_class, context)Create the Druid component instance
-
Parameters:
self(druid.instance): The Druid Factory used to create componentswidget_class(druid.widget):context(table):
-
Returns:
- `` (druid.widget):
component:init()Called when component is created
component:update()Called every frame
component:on_remove()Called when component is removed
component:on_input()Called when input event is triggered
component:on_input_interrupt()Called when input event is consumed before
component:on_message()Called when message is received
component:on_late_init()Called before update once time after GUI init
component:on_focus_lost()Called when app lost focus
component:on_focus_gained()Called when app gained focus
component:on_style_change()Called when style is changed
component:on_layout_change()Called when GUI layout is changed
component:on_window_resized()Called when window is resized
component:on_language_change()Called when language is changed
component:set_style([druid_style])Set component style. Pass nil to clear style
-
Parameters:
[druid_style](table|nil):
-
Returns:
self(): The component itself for chaining
component:set_template([template])Set component template name. Pass nil to clear template. This template id used to access nodes inside the template on GUI scene. Parent template will be added automatically if exist.
-
Parameters:
[template](string|nil):
-
Returns:
self(): The component itself for chaining
component:get_template()Get full template name.
- Returns:
- `` (string):
component:set_nodes([nodes])Set current component nodes, returned from gui.clone_tree function.
-
Parameters:
[nodes](string|node|table<hash, node>|nil): The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
-
Returns:
- `` (druid.component):
component:get_context()Return current component context
- Returns:
context(any): Usually it's self of script but can be any other Druid component
component:get_node(node_id)Get component node by node_id. Respect to current template and nodes.
-
Parameters:
node_id(string|node):
-
Returns:
- `` (node):
component:get_druid([template], [nodes])Get Druid instance for inner component creation.
-
Parameters:
[template](string|nil):[nodes](string|node|table<hash, node>|nil): The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
-
Returns:
- `` (druid.instance):
component:get_name()Get component name
- Returns:
name(string): The component name + uid
component:get_parent_name()Get parent component name
- Returns:
parent_name(string|nil): The parent component name if exist or nil
component:get_input_priority()Get component input priority, the bigger number processed first. Default value: 10
- Returns:
- `` (number):
component:set_input_priority(value, [is_temporary])Set component input priority, the bigger number processed first. Default value: 10
-
Parameters:
value(number):[is_temporary](boolean|nil): If true, the reset input priority will return to previous value
-
Returns:
self(druid.component): The component itself for chaining
component:reset_input_priority()Reset component input priority to it's default value, that was set in create function or set_input_priority
- Returns:
self(druid.component): The component itself for chaining
component:get_uid()Get component UID, unique identifier created in component creation order.
- Returns:
uid(number): The component uid
component:set_input_enabled(state)Set component input state. By default it's enabled. If input is disabled, the component will not receive input events. Recursive for all children components.
-
Parameters:
state(boolean):
-
Returns:
self(druid.component): The component itself for chaining
component:get_input_enabled()Get component input state. By default it's enabled. Can be disabled by set_input_enabled function.
- Returns:
- `` (boolean):
component:get_parent_component()Get parent component
- Returns:
parent_component(druid.component|nil): The parent component if exist or nil
component:get_nodes()Get current component nodes
- Returns:
- `` (table<hash, node>|nil):
component:get_childrens()Return all children components, recursive
- Returns:
Array(table): of childrens if the Druid component instance
- druid (druid.instance): Druid instance to create inner components