-- Simple Drag And Drop Handler
-- (c) Simon Scheckel 2015
local state_mousedown = false
function dragDropHandler(eventType, mousePosition)
if eventType == eEvtMouseLeftButtonUp or eventType == eEvtMouseLeftButtonHold then
-- generateEvent(eEvtMouse)
state_mousedown = false
elseif eventType == eEvtMouseLeftButtonDown then
state_mousedown = true
if game.CurrentObject:getId().tableId == eObjects and game.CurrentObject.IsItem then
game.UsedItem = game.CurrentObject
game.UsedItemPicked = true
end
elseif eventType == eEvtMouseMove and state_mousedown == false then
game.UsedItem = emptyObject
game.UsedItemPicked = false
elseif eventType == eEvtMouseMove then
if game.UsedItem:getId().id ~= -1 and game.CurrentObject:getId().tableId == eObjects then
-- setCursorPos(game.CurrentObject.Polygon[1])
end
end
end
registerEventHandler("mouseEvent", "dragDropHandler", { eEvtMouseLeftButtonUp, eEvtMouseLeftButtonDown, eEvtMouseMove, eEvtMouseLeftButtonHold})