Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/linux/src/Rtt_LinuxDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace Rtt
case MPlatformDevice::kHeadingEvent:
case MPlatformDevice::kMultitouchEvent:
case MPlatformDevice::kKeyEvent:
case MPlatformDevice::kMouseEvent:
case MPlatformDevice::kAccelerometerEvent:
hasEventSource = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/Rtt_MacDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,11 @@
case MPlatformDevice::kGyroscopeEvent:
case MPlatformDevice::kMultitouchEvent:
case MPlatformDevice::kHeadingEvent:
case MPlatformDevice::kMouseEvent:
hasEventSource = false;
break;
case MPlatformDevice::kLocationEvent:
case MPlatformDevice::kKeyEvent:
case MPlatformDevice::kMouseEvent:
case MPlatformDevice::kInputDeviceStatusEvent:
hasEventSource = true;
break;
Expand Down
10 changes: 5 additions & 5 deletions platform/resources/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ Runtime._proxy =

local needsHardwareSupport = { orientation=true, accelerometer=true, gyroscope=true, location=true, heading=true }

function Runtime:addEventListener( eventName, listener )
function Runtime:addEventListener( eventName, listener, suppressSimulatorWarning )
local super = self._super
local noListeners = not self:respondsToEvent( eventName )
local wasAdded = super.addEventListener( self, eventName, listener )

-- If a "key" event listener is installed on a simulated iOS/tvOS/WinPhone device,
-- warn it wont be effective on a real device
if eventName and eventName == "key" and system.getInfo("environment") == "simulator" then
-- If a "key" or "mouse" listener is added on a simulated iOS/tvOS/WinPhone device, warn it won't
-- fire on a real device. The Simulator's own internal mouse listener passes suppressSimulatorWarning.
if not suppressSimulatorWarning and eventName and (eventName == "key" or eventName == "mouse") and system.getInfo("environment") == "simulator" then
local osName = system.getInfo("platform")
if osName == "ios" or osName == "tvos" or osName == "winphone" then
print("WARNING: Runtime:addEventListener: real "..osName.." devices don't generate 'key' events")
print("WARNING: Runtime:addEventListener: real "..osName.." devices don't generate '"..eventName.."' events")
end
end

Expand Down
5 changes: 5 additions & 0 deletions platform/shared/Rtt_PlatformSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,14 @@ PlatformSimulator::LoadConfig( const char deviceConfigFile[], Config& rConfig )
rConfig.supportsMouse = false;
switch (rConfig.platform)
{
// In the Simulator we allow mouse events in all skins though we
// warn if the simulated device doesn't support them (see init.lua)
case TargetDevice::kAndroidPlatform:
case TargetDevice::kIPhonePlatform:
case TargetDevice::kOSXPlatform:
case TargetDevice::kTVOSPlatform:
case TargetDevice::kWin32Platform:
case TargetDevice::kWinPhoneSilverlightPlatform:
rConfig.supportsMouse = true;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,16 @@ class LuaMethodCallback

@param eventName The name of the event, such as "enterFrame".

@param suppressSimulatorWarning When true, Runtime:addEventListener skips its warning that the
simulated device would not generate this event on real hardware (used for Simulator-internal listeners).

@return
Returns true if the Lua Runtime function was successfully called.

Returns false if given a null "eventName" argument, if this callback's Lua function is no longer registered,
or if failed to access the Lua Runtime object.
*/
bool AddToRuntimeEventListeners(const char* eventName)
bool AddToRuntimeEventListeners(const char* eventName, bool suppressSimulatorWarning = false)
{
// Validate.
if (!fLuaStatePointer || !eventName || (LUA_NOREF == fLuaRegistryReferenceId))
Expand All @@ -262,7 +265,10 @@ class LuaMethodCallback
lua_insert(fLuaStatePointer, -2);
lua_pushstring(fLuaStatePointer, eventName);
lua_rawgeti(fLuaStatePointer, LUA_REGISTRYINDEX, fLuaRegistryReferenceId);
CoronaLuaDoCall(fLuaStatePointer, 3, 0);
// 4th arg lets Runtime:addEventListener suppress its simulated-device warning for this
// internally-added listener (see init.lua).
lua_pushboolean(fLuaStatePointer, suppressSimulatorWarning ? 1 : 0);
CoronaLuaDoCall(fLuaStatePointer, 4, 0);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ void SimulatorRuntimeEnvironment::OnRuntimeLoaded(RuntimeEnvironment& sender, co

// Add Lua event listeners.
fLuaMouseEventCallback.RegisterTo(sender.GetRuntime()->VMContext().L());
fLuaMouseEventCallback.AddToRuntimeEventListeners("mouse");
// true: this is the Simulator's own listener, so don't warn about the simulated device (see init.lua).
fLuaMouseEventCallback.AddToRuntimeEventListeners("mouse", true);
}

void SimulatorRuntimeEnvironment::OnRuntimeTerminating(RuntimeEnvironment& sender, const EventArgs& arguments)
Expand Down