# Defold Druid UI Library

# Module `Button`

Component to handle basic GUI button

## Functions

init(self, node, callback[, params[, anim_node]]) | Component init function
set_enabled(self, state) | Set enabled button component state
is_enabled(self) | Return button enabled state
set_click_zone(self, zone) | Strict button click area.
set_key_trigger(self, key) | Set key-code to trigger this button
get_key_trigger(self) | Get key-code to trigger this button

## Tables

style | Component style params.

## Fields

on_click | On release button callback(self, params, button_instance)
on_repeated_click | On repeated action button callback(self, params, button_instance, click_amount)
on_long_click | On long tap button callback(self, params, button_instance, time)
on_double_click | On double tap button callback(self, params, button_instance, click_amount)
on_hold_callback | On button hold before long_click callback(self, params, button_instance, time)
on_click_outside | On click outside of button(self, params, button_instance)
node | Trigger node
anim_node | Animation node
start_scale | Initial scale of anim_node
start_pos | Initial pos of anim_node
pos | Initial pos of anim_node
params | Params to click callbacks
hover | Druid hover logic component
click_zone | Restriction zone

## Functions

init(self, node, callback[, params[, anim_node]])
  Component init function

  ### Parameters:

  - self Button
  - 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)
set_enabled(self, state)
  Set enabled button component state

  ### Parameters:

  - self Button
  - state bool Enabled state

  ### Returns:

  Button Current button instance
is_enabled(self)
  Return button enabled state

  ### Parameters:

  - self Button

  ### Returns:

  bool True, if button is enabled
set_click_zone(self, zone)
  Strict button click area. Useful for no click events outside stencil node

  ### Parameters:

  - self Button
  - zone node Gui node

  ### Returns:

  Button Current button instance
set_key_trigger(self, key)
  Set key-code to trigger this button

  ### Parameters:

  - self Button
  - key hash The action_id of the key

  ### Returns:

  Button Current button instance
get_key_trigger(self)
  Get key-code to trigger this button

  ### Parameters:

  - self Button

  ### Returns:

  hash The action_id of the key

## Tables

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

  ### Fields:

  - LONGTAP_TIME number Minimum time to trigger on_hold_callback (default 0.4)
  - AUTOHOLD_TRIGGER number Maximum hold time to trigger button release while holding (default 0.8)
  - DOUBLETAP_TIME number Time between double taps (default 0.4)
  - on_click function (self, node)
  - on_click_disabled function (self, node)
  - on_hover function (self, node, hover_state)
  - on_mouse_hover function (self, node, hover_state)
  - on_set_enabled function (self, node, enabled_state)

## Fields

on_click
  On release button callback(self, params, button_instance)
  - on_click druid_event
on_repeated_click
  On repeated action button callback(self, params, button_instance, click_amount)
  - on_repeated_click druid_event
on_long_click
  On long tap button callback(self, params, button_instance, time)
  - on_long_click druid_event
on_double_click
  On double tap button callback(self, params, button_instance, click_amount)
  - on_double_click druid_event
on_hold_callback
  On button hold before long_click callback(self, params, button_instance, time)
  - on_hold_callback druid_event
on_click_outside
  On click outside of button(self, params, button_instance)
  - on_click_outside druid_event
node
  Trigger node
  - node node
anim_node
  Animation node
  - anim_node node (default node)
start_scale
  Initial scale of anim_node
  - start_scale vector3
start_pos
  Initial pos of anim_node
  - start_pos vector3
pos
  Initial pos of anim_node
  - pos vector3
params
  Params to click callbacks
  - params any
hover
  Druid hover logic component
  - hover druid.hover
click_zone
  Restriction zone
  - click_zone node (optional)

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