Functions
- scrupp.getMouseX()
- Returns the current x-coordinate of the mouse pointer.
- scrupp.getMouseY()
- Returns the current y-coordinate of the mouse pointer.
- scrupp.getMousePos()
- Returns the current x- and y-coordinate of the mouse pointer
- scrupp.mouseButtonIsDown(button)
- Returns the boolean state of the button.
button is one of the strings "left", "middle" or
"right".
Callbacks
- mousepressed(x, y, button)
- Gets called when a mouse button is pressed. Arguments are the
x- and the y-coordinate of the mouse pointer and
the pressed button. button is one of the strings
"left", "middle", "right", "wheelUp" or "wheelDown".
- mousereleased(x, y, button)
- Gets called when a mouse button is released. Arguments are the
x- and the y-coordinate of the mouse pointer and
the released button. button is one of the strings
"left", "middle", "right", "wheelUp" or "wheelDown".
Example
scrupp.init("Mouse Test", 600, 400, 32, false)
require "font"
local font = Font("fonts/Vera.ttf", 20)
local text = ""
local cursor = scrupp.addImage("path_to_cursor_image")
main = {
render = function(dt)
font:print(10,10, text)
if scrupp.mouseButtonIsDown("left") then
cursor:render(scrupp.getMouseX(), scrupp.getMouseY())
--or: cursor:render(scrupp.getMousePos())
end
end,
mousepressed = function(x, y, button)
text = button .." button pressed at "..x..", "..y
end,
mousereleased = function(x, y, button)
text = button .." button released at "..x..", "..y
end
}