event.x

Type Number
Event mouse
Revision Release 2024.3703
Keywords mouse, x

Overview

The mouse cursor’s current x position on screen in content coordinates.

Example

-- Called when a mouse event has been received.
local function onMouseEvent( event )
    -- Print the mouse cursor's current position to the log.
    local message = "Mouse Position = (" .. tostring(event.x) .. "," .. tostring(event.y) .. ")"
    print( message )
end
                             
-- Add the mouse event listener.
Runtime:addEventListener( "mouse", onMouseEvent )