# Defold Druid UI Library

# Module `druid.button`

Component to handle basic GUI button

## Functions

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

## Tables

Events | Component events
Fields | Component fields
Style | Component style params.

## Functions

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

  ### Parameters:

  - 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(state)
  Set enabled button component state

  ### Parameters:

  - state bool Enabled state

  ### Returns:

  druid.button Current button instance
is_enabled()
  Return button enabled state

  ### Returns:

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

  ### Parameters:

  - zone node Gui node

  ### Returns:

  druid.button Current button instance
set_key_trigger(key)
  Set key-code to trigger this button

  ### Parameters:

  - key hash The action_id of the key

  ### Returns:

  druid.button Current button instance
get_key_trigger()
  Get key-code to trigger this button

  ### Returns:

  hash The action_id of the key

## Tables

Events
  Component events

  ### Fields:

  - on_click druid_event (self, params, button_instance) On release button callback
  - on_repeated_click druid_event (self, params, buttoninstance, clickamount) On repeated action button callback
  - on_long_click druid_event (self, params, button_instance, time) On long tap button callback
  - on_double_click druid_event (self, params, buttoninstance, clickamount) On double tap button callback
  - on_hold_callback druid_event (self, params, buttoninstance, time) On button hold before longclick callback
  - on_click_outside druid_event (self, params, button_instance) On click outside of button
Fields
  Component fields

  ### Fields:

  - node node Trigger node
  - anim_node node Animation node (default node)
  - start_scale vector3 Initial scale of anim_node
  - start_pos vector3 Initial pos of anim_node
  - pos vector3 Initial pos of anim_node
  - params any Params to click callbacks
  - hover druid.hover Druid hover logic component
  - click_zone node Restriction zone (optional)
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 onholdcallback (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)

generated by LDoc 1.4.6 Last updated 2020-06-14 20:13:02