event.scrollX

类型 数字
事件 mouse
修订版 发行版 2024.3703
关键字 mouse、scrollX

概述

鼠标滚动的当前x 滚动值。此值取决于用户的鼠标设置。

示例

-- Called when a mouse event has been received.
local function onMouseEvent( event )
    if event.type == "scroll" then
        if event.scrollX < 0 then
            print( "Mouse is scrolling left with a value of " .. event.scrollX .. "." )
        elseif event.scrollX > 0 then
            print( "Mouse is scrolling right with a value of " .. event.scrollX .. "." )
        end
    end
end

-- Add the mouse event listener.
Runtime:addEventListener( "mouse", onMouseEvent )