event.isMiddleButtonDown
ប្រើសំរាប់បង្ហាញបើសិនជា mouse’s middle button was held down at the time the mouse event បានកើតឡើង។ សំរាប់ android devices older than v4 do not support the middle mouse button
សូមមើលកូដះ
-- Called when a mouse event has been received.
local function onMouseEvent( event )
if event.isMiddleButtonDown then
-- The mouse's middle button is currently pressed down.
else
-- The mouse's middle button is not being pressed.
end
end
-- Add the mouse event listener.
Runtime:addEventListener( "mouse", onMouseEvent )
event.name
ជា String “mouse”
event.time
វាជា time this mouse event ដែលកើតឡើងនៅក្នុង milliseconds ចាប់តាំងពីកម្មវិធីចាប់ផ្តើម
សូមមើលកូដះ
-- Called when a mouse event has been received.
local function onMouseEvent( event )
-- Print the mouse event's timestamp to the log.
local message = "Mouse Event Timestamp = " .. tostring(event.time)
print( message )
end
-- Add the mouse event listener.
Runtime:addEventListener( "mouse", onMouseEvent )
event.x
ប្រើសំរាប់ mouse cursor’s current x position on screen in content coordinates
សូមមើលកូដះ
-- 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 )
event.y
ប្រើសំរាប់ mouse cursor’s current y position នៅលើអេក្រង់នៅក្នុង content coordinates
សូមមើលកូដះ
-- 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 )
No comments:
Post a Comment