local timer = getTime() -- create the initial timer variable
local tState = 0 -- set the initial state of the timer (mainLoop only checks if state = "1")
local tHoldTime = 500 -- time value is in ms
-- let's create the function for the mainLoop handler!
function onMainLoop()
if tState == 1 and timer >= tHoldTime then
tState = 0 -- reset state back to default...
-- do some action
end
end
-- let's create the function for the mouseEvent listener!
function onMouseEvent(eventType, mousePosition)
if eventType == eEvtRightButtonDown then timer = getTime({flags=1, reset=true}); tState = 1 end
if eventType == eEvtRightButtonUp then tState = 0 end
end
-- let's create the mouseEvent listener!
registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseMove, eEvtMouseLeftButtonDoubleClick, eEvtMouseLeftButtonDown, eEvtMouseLeftButtonUp, eEvtMouseLeftButtonHold, eEvtMouseLeftButtonHolding, eEvtMouseRightButtonDoubleClick, eEvtMouseRightButtonDown, eEvtMouseRightButtonUp, eEvtMouseMiddleButtonDown, eEvtMouseMiddleButtonUp, eEvtMouseWheelUp, eEvtMouseWheelDown})
-- let's create the loop handler!
registerEventHandler("mainLoop", "onMainLoop")