Skip to content

Latest commit

 

History

History
211 lines (147 loc) · 4.6 KB

drag_api.md

File metadata and controls

211 lines (147 loc) · 4.6 KB

druid.drag API

at /druid/base/drag.lua

A component that allows you to subscribe to drag events over a node

Functions

Fields

init


drag:init(node_or_node_id, [on_drag_callback])

The constructor for Drag component

  • Parameters:
    • node_or_node_id (string|node): The node to subscribe to drag events over
    • [on_drag_callback] (fun(self: any, touch: any)): The callback to call when a drag occurs

set_drag_cursors


drag:set_drag_cursors(is_enabled)

Enable or disable drag cursors from the Drag style. No-op without defos or without cursors in style. Hover is created on first enable.

  • Parameters:
    • is_enabled (boolean): True if Drag cursors are enabled

set_click_zone


drag:set_click_zone([node])

Set Drag click zone

  • Parameters:

    • [node] (string|node|nil): Node or node id
  • Returns:

    • self (druid.drag): Current instance

set_enabled


drag:set_enabled(is_enabled)

Set Drag component enabled state.

  • Parameters:

    • is_enabled (boolean):
  • Returns:

    • self (druid.drag): Current instance

is_enabled


drag:is_enabled()

Check if Drag component is capture input

  • Returns:
    • is_enabled (boolean): True if Drag component is enabled

add_drag_action


drag:add_drag_action(action_id)

Add an additional input action that can start a drag. By default only touch and multitouch actions are allowed. Useful to drag with the middle or right mouse button on desktop. The action should provide the pointer position, key actions are ignored.

  • Parameters:

    • action_id (hash): The action id to allow for dragging
  • Returns:

    • self (druid.drag): Current instance

remove_drag_action


drag:remove_drag_action(action_id)

Remove an additional input action from the allowed drag actions

  • Parameters:

    • action_id (hash): The action id to disallow for dragging
  • Returns:

    • self (druid.drag): Current instance

Fields

  • node (node): The node to subscribe to drag events over

  • on_touch_start (event): fun(self, touch) The event triggered when a touch starts

  • on_touch_end (event): fun(self, touch) The event triggered when a touch ends

  • on_drag_start (event): fun(self, touch) The event triggered when a drag starts

  • on_drag (event): fun(self, touch) The event triggered when a drag occurs

  • on_drag_end (event): fun(self, touch) The event triggered when a drag ends

  • style (druid.drag.style): The style of Drag component

  • click_zone (node): The click zone of Drag component

  • is_touch (boolean): True if a touch is active

  • is_drag (boolean): True if a drag is active

  • can_x (boolean): True if Drag can move horizontally

  • can_y (boolean): True if Drag can move vertically

  • dx (number): The horizontal drag distance

  • dy (number): The vertical drag distance

  • touch_id (number): The touch id

  • x (number): The current x position

  • y (number): The current y position

  • screen_x (number): The current screen x position

  • screen_y (number): The current screen y position

  • touch_start_pos (vector3): The touch start position

  • hover (druid.hover|nil): Hover for drag cursors. nil without defos

  • druid (druid.instance): The Druid Factory used to create components