Skip to content

Windows: enable mouse events in Simulator on all skins#925

Open
XeduR wants to merge 1 commit into
coronalabs:masterfrom
XeduR:mouse-events
Open

Windows: enable mouse events in Simulator on all skins#925
XeduR wants to merge 1 commit into
coronalabs:masterfrom
XeduR:mouse-events

Conversation

@XeduR

@XeduR XeduR commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

I've spent too many hours on Windows debugging why mouse events weren't firing only to remember that I was simulating an iOS device. 😅 Currently adding mouse events just fails silently on Simulator, but key events work just fine and they just give out a warning when simulating unsupported devices, so I replicated that behaviour for mouse events.

Changes

  • Add iOS/tvOS/WinPhone to the Simulator's supportsMouse config so mouse events fire on those skins (they were blocked on Windows), matching how key events already warn-and-fire
    • Just adding Windows Phone here since the option exists in the Simulator (in case some poor soul selects it)
  • Extend the init.lua simulated-device warning to cover "mouse" as well as "key", reminding devs the events won't fire on a real devices
  • Report mouse as an available event source on macOS and Linux so Runtime:hasEventSource("mouse") returns true instead of returning false / asserting in debug
  • Also adding a third optional suppressSimulatorWarning parameter to Runtime:addEventListener to suppress "key" and "mouse" warnings on the Simulator
    • Making the Simulator's/Welcome Screen's own internal mouse-cursor listener suppress warnings so it won't fire every time when simulating unsupported devices/skins

To test

Create an empty projects and just copy this to main.lua. Then run the project on the Simulator while simulating iOS, tvOS or Windows Phone device.

-- 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 )

-- Optionally, suppress the warning on the Simulator.
-- Runtime:addEventListener( "mouse", onMouseEvent, true )

- Add iOS/tvOS/WinPhone to the Simulator's supportsMouse config so mouse events fire on those skins (they were blocked on Windows), matching how key events already warn-and-fire
  - Just adding Windows Phone here since the option exists in the Simulator (in case some poor soul selects it)
- Extend the init.lua simulated-device warning to cover "mouse" as well as "key", reminding devs the events won't fire on a real devices
- Report mouse as an available event source on macOS and Linux so Runtime:hasEventSource("mouse") returns true instead of returning false / asserting in debug
- Also adding a third optional suppressSimulatorWarning parameter to Runtime:addEventListener to suppress "key" and "mouse" warnings on the Simulator
  - Making the Simulator's/Welcome Screen's own internal mouse-cursor listener suppress warnings so it won't fire every time when simulating unsupported devices/skins
@XeduR XeduR requested a review from Shchvova as a code owner June 10, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant