tibia-client/modules/corelib/mouse.lua

37 lines
1.1 KiB
Lua
Raw Normal View History

2012-06-26 00:13:30 +02:00
-- @docclass
function g_mouse.bindAutoPress(widget, callback, delay, button)
local button = button or MouseLeftButton
connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
if mouseButton ~= button then
return false
end
local startTime = g_clock.millis()
callback(widget, mousePos, mouseButton, 0)
periodicalEvent(function()
callback(widget, g_window.getMousePosition(), mouseButton, g_clock.millis() - startTime)
end, function()
return g_mouse.isPressed(mouseButton)
end, 30, delay)
return true
end })
end
2012-06-26 00:13:30 +02:00
function g_mouse.bindPressMove(widget, callback)
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
if widget:isPressed() then
callback(mousePos, mouseMoved)
2013-02-10 06:24:51 +01:00
return true
end
end })
end
function g_mouse.bindPress(widget, callback, button)
connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
if not button or button == mouseButton then
callback(mousePos, mouseButton)
return true
end
return false
end })
end