Module Drag
Component to handle drag action on node.
Drag have correct handling for multitouch and swap
touched while dragging. Drag will be processed even
the cursor is outside of node, if drag is already started
Example Link
style |
Component style params. |
can_x |
Is drag component process vertical dragging. |
can_y |
Is drag component process horizontal. |
is_drag |
Is component now dragging |
is_touch |
Is component now touching |
node |
Drag node |
on_drag |
on drag progress callback(self, dx, dy, total_x, total_y, touch) |
on_drag_end |
Event on drag end callback(self, total_x, total_y, touch) |
on_drag_start |
Event on drag start callback(self, touch) |
on_touch_end |
Event on touch end callback(self) |
on_touch_start |
Event on touch start callback(self) |
screen_x |
Current touch x screen position |
screen_y |
Current touch y screen position |
touch_start_pos |
Touch start position |
x |
Current touch x position |
y |
Current touch y position |
-
init(self, node, on_drag_callback)
-
The Drag constructor
Parameters:
- self
Drag
Drag
- node
node
GUI node to detect dragging
- on_drag_callback
function
Callback for on_drag_event(self, dx, dy)
-
is_enabled(self)
-
Check if Drag component is enabled
Parameters:
Returns:
boolean
-
set_click_zone(self, node)
-
Strict drag click area. Useful for
restrict events outside stencil node
Parameters:
-
set_enabled(self, is_enabled)
-
Set Drag input enabled or disabled
Parameters:
- self
Drag
Drag
- is_enabled
boolean or nil
-
style
-
Component style params.
You can override this component styles params in druid styles table
or create your own style
Fields:
- DRAG_DEADZONE
number or nil
Distance in pixels to start dragging. Default: 10
- NO_USE_SCREEN_KOEF
boolean or nil
If screen aspect ratio affects on drag values. Default: false
-
can_x
-
Is drag component process vertical dragging. Default - true
-
can_y
-
Is drag component process horizontal. Default - true
-
is_drag
-
Is component now dragging
-
is_touch
-
Is component now touching
-
node
-
Drag node
-
on_drag
-
on drag progress callback(self, dx, dy, total_x, total_y, touch)
-
on_drag_end
-
Event on drag end callback(self, total_x, total_y, touch)
-
on_drag_start
-
Event on drag start callback(self, touch)
-
on_touch_end
-
Event on touch end callback(self)
-
on_touch_start
-
Event on touch start callback(self)
-
screen_x
-
Current touch x screen position
-
screen_y
-
Current touch y screen position
-
touch_start_pos
-
Touch start position
-
x
-
Current touch x position
-
y
-
Current touch y position