27 lines
622 B
Lua
27 lines
622 B
Lua
local Event = {}
|
|
|
|
function Event.isClickEvent(evt)
|
|
return evt[1] == "monitor_touch" or evt[1] == "mouse_click"
|
|
end
|
|
|
|
function Event.getClickParams(evt)
|
|
return evt[3], evt[4], evt[2]
|
|
end
|
|
|
|
function Event.repositionEvent(evt, dX, dY)
|
|
if Event.isClickEvent(evt) then
|
|
return evt[1], evt[2], evt[3] + dX, evt[4] + dY
|
|
else
|
|
return evt
|
|
end
|
|
end
|
|
|
|
function Event.containsClick(element, evt, dX, dY)
|
|
local x, y = Event.getClickParams(evt)
|
|
x = x + dX
|
|
y = y + dY
|
|
local eX, eY = element:getPos()
|
|
return x >= eX and x < (eX + element:getWidth()) and y >= eY and y < (eY + element:getHeight())
|
|
end
|
|
|
|
return Event |