πdrag-drop
drag and drop library
example of usage:
local dragging = require("morion/drag-drop")
local x_pos = ui:new_slider_int("x pos", 50, engine.get_screen_size( ).x)
local y_pos = ui:new_slider_int("y pos", 50, engine.get_screen_size( ).y)
local new_drag_obj = dragging.push({ x, y }, vector_2d(100, 100), "new-object", function(self)
draw.rect_filled( self.position.x, self.position.y, self.size.x, self.size.y, color_rgb(255, 255, 255) )
end)
callbacks.init("on_paint", function()
new_drag_obj:draw()
-- saving x & y for new_drag_obj
for k, v in pairs(new_drag_obj:get_elements()) do
v:set( k == "x" and new_drag_obj:get_position().x or new_drag_obj:get_position().y )
end
end)functions:
push
classes:
draw
get_elements
get_position
Last updated