diff --git a/librtt/Rtt_Event.cpp b/librtt/Rtt_Event.cpp index 6066ccab5..5d48cef77 100755 --- a/librtt/Rtt_Event.cpp +++ b/librtt/Rtt_Event.cpp @@ -1802,7 +1802,6 @@ HitEvent::DispatchFocused( lua_State *L, Runtime& runtime, StageObject& stage, D Rtt_ASSERT( focus ); bool handled = false; - ScreenToContent( runtime.GetDisplay(), fXScreen, fYScreen, fXContent, fYContent ); // If we have focus, then dispatch only to that object or its ancestors @@ -1865,9 +1864,10 @@ HitEvent::Dispatch( lua_State *L, Runtime& runtime ) const StageObject& stage = * display.GetStage(); DisplayObject* focus = stage.GetFocus(); bool handled = false; + if ( focus ) { - handled = DispatchFocused( L, runtime, stage, focus ); + handled = DispatchFocused( L, runtime, stage, focus); } else { @@ -2044,9 +2044,7 @@ TouchEvent::TouchEvent() fYStartScreen( Rtt_REAL_0 ), fXStartContent( Rtt_REAL_0 ), fYStartContent( Rtt_REAL_0 ), - fPressure( kPressureInvalid ), - fDeltaX( Rtt_REAL_0 ), - fDeltaY( Rtt_REAL_0 ) + fPressure( kPressureInvalid ) { } @@ -2058,9 +2056,7 @@ TouchEvent::TouchEvent( Real x, Real y, Real xStartScreen, Real yStartScreen, Ph fYStartScreen( yStartScreen ), fXStartContent( xStartScreen ), fYStartContent( yStartScreen ), - fPressure( pressure ), - fDeltaX( x - xStartScreen ), - fDeltaY( y - yStartScreen ) + fPressure( pressure ) { } @@ -2085,14 +2081,16 @@ TouchEvent::Push( lua_State *L ) const lua_pushstring( L, StringForPhase( (Phase)fPhase ) ); lua_setfield( L, -2, kPhaseKey ); - + lua_pushnumber( L, Rtt_RealToFloat( fXStartContent ) ); lua_setfield( L, -2, kXStartKey ); lua_pushnumber( L, Rtt_RealToFloat( fYStartContent ) ); lua_setfield( L, -2, kYStartKey ); - lua_pushinteger( L, Rtt_RealToInt( fDeltaX) ); + + + lua_pushnumber( L, X()-Rtt_RealToFloat( fXStartContent ) ); lua_setfield( L, -2, kXDeltaKey ); - lua_pushinteger( L, Rtt_RealToInt( fDeltaY )); + lua_pushnumber( L, Y()-Rtt_RealToFloat( fYStartContent )); lua_setfield( L, -2, kYDeltaKey ); if ( fPressure >= kPressureThreshold ) @@ -2115,7 +2113,7 @@ void TouchEvent::Dispatch( lua_State *L, Runtime& runtime ) const { ScreenToContent( runtime.GetDisplay(), fXStartScreen, fYStartScreen, fXStartContent, fYStartContent ); - + Super::Dispatch( L, runtime ); } @@ -2173,8 +2171,7 @@ MultitouchEvent::Dispatch( lua_State *L, Runtime& runtime ) const if ( object ) { // Dispatch focused per-object touch events - e.DispatchFocused( L, runtime, stage, object ); - + e.DispatchFocused( L, runtime, stage, object); // Cleanup: remove per-object focus at the end of the touch (e.g. phase is "ended" or "cancelled") if ( shouldCleanup ) { diff --git a/librtt/Rtt_Event.h b/librtt/Rtt_Event.h index 28b6f96de..370754948 100755 --- a/librtt/Rtt_Event.h +++ b/librtt/Rtt_Event.h @@ -934,8 +934,6 @@ class TouchEvent : public HitEvent public: bool IsProperty( U16 mask ) const { return (fProperties & mask) != 0; } void SetProperty( U16 mask, bool value ); - Rtt_FORCE_INLINE Real DeltaX() const { return fDeltaX; }; - Rtt_FORCE_INLINE Real DeltaY() const { return fDeltaY; }; private: U16 fPhase; @@ -945,8 +943,7 @@ class TouchEvent : public HitEvent mutable Real fXStartContent; mutable Real fYStartContent; Real fPressure; - Real fDeltaX; - Real fDeltaY; + }; // ----------------------------------------------------------------------------