类型 事件 修订 2024.3703 版 关键字 鼠标
当鼠标光标移动或鼠标按钮按或松开时,就会发生鼠标事件。此事件提供有关鼠标光标当前屏幕坐标及其按钮状态的信息。
请注意,当按下鼠标主按钮时,鼠标会生成 触摸 事件。
另请注意,单击鼠标主按钮时,鼠标会生成 轻拍 事件。单击一次时,轻拍的 event.numTaps 属性将设置为 1,双击时将设置为 2。单击任何其他鼠标按钮时,不会触发 轻拍 事件。
只有 Android 3.1 或更高版本的设备通过蓝牙或 USB 支持鼠标。
Android 3.1 和 3.2 仅支持鼠标的主按钮。在这些 Android 操作系统版本中,event.isSecondaryButtonDown 和 event.isMiddleButtonDown 属性始终为 false。
Android 4.0 及更高版本的设备支持鼠标的次级和中级按钮。
不支持鼠标事件。
macOS 和 macOS 桌面应用程序的 Corona Simulator 支持鼠标事件。
Windows 和 Win32 桌面应用程序的 Corona Simulator 支持鼠标事件。然而,在 Corona Simulator 中,仅在模拟 Android 设备时才提供鼠标事件。
当鼠标光标不在应用程序窗口内时,不会收到鼠标事件,例如当您将光标拖到 Android 底部导航栏顶部时。
-- Called when a mouse event has been received. local function onMouseEvent( event ) if event.type == "down" then if event.isPrimaryButtonDown then print( "Left mouse button clicked." ) elseif event.isSecondaryButtonDown then print( "Right mouse button clicked." ) end end end -- Add the mouse event listener. Runtime:addEventListener( "mouse", onMouseEvent )