tibia-client/modules/corelib/mouse.lua

54 lines
1.2 KiB
Lua
Raw Normal View History

2012-01-08 16:42:23 +01:00
Mouse = {}
2012-03-29 00:42:02 +02:00
local cursorChanged = false
function Mouse.setTargetCursor()
2012-06-19 10:46:49 +02:00
g_window.setMouseCursor('/cursors/targetcursor.png', {x=9,y=9})
cursorChanged = true
end
function Mouse.setHorizontalCursor()
2012-06-19 10:46:49 +02:00
g_window.setMouseCursor('/cursors/horizontal.png', {x=9,y=4})
cursorChanged = true
end
function Mouse.setVerticalCursor()
2012-06-19 10:46:49 +02:00
g_window.setMouseCursor('/cursors/vertical.png', {x=4,y=9})
cursorChanged = true
end
function Mouse.restoreCursor()
g_window.restoreMouseCursor()
cursorChanged = false
end
function Mouse.isCursorChanged()
return cursorChanged
end
function Mouse.isPressed(button)
if not button then button = MouseLeftButton end
return g_window.isMouseButtonPressed(button)
end
function Mouse.bindAutoPress(widget, callback)
connect(widget, { onMousePress = function(widget, mousePos, mouseButton)
callback()
periodicalEvent(function()
callback()
end, function()
return widget:isPressed()
end, 30, 300)
return true
end })
end
function Mouse.bindPressMove(widget, callback)
connect(widget, { onMouseMove = function(widget, mousePos, mouseMoved)
if widget:isPressed() then
callback(mousePos, mouseMoved)
end
return true
end })
end