diff --git a/ReactWindows/ReactNative.Net46/Touch/TouchHandler.cs b/ReactWindows/ReactNative.Net46/Touch/TouchHandler.cs index 99be79e1b42..34a180c2e85 100644 --- a/ReactWindows/ReactNative.Net46/Touch/TouchHandler.cs +++ b/ReactWindows/ReactNative.Net46/Touch/TouchHandler.cs @@ -60,7 +60,8 @@ private void OnTouchPressed(object sender, TouchEventArgs e) pointer.IsHorizontalMouseWheel = false; pointer.IsEraser = false; pointer.ReactView = reactView; - UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint); + var timestamp = e.Timestamp; + UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint, timestamp); var pointerIndex = _pointers.Count; _pointers.Add(pointer); @@ -88,7 +89,8 @@ private void OnMouseDown(object sender, MouseButtonEventArgs e) pointer.IsHorizontalMouseWheel = false; pointer.IsEraser = false; pointer.ReactView = reactView; - UpdatePointerForEvent(pointer, rootPoint, viewPoint); + var timestamp = e.Timestamp; + UpdatePointerForEvent(pointer, rootPoint, viewPoint, timestamp); var pointerIndex = _pointers.Count; _pointers.Add(pointer); @@ -108,11 +110,12 @@ private void OnTouchMoved(object sender, TouchEventArgs e) private void OnMouseMove(object sender, MouseEventArgs e) { - if (_pointers != null && _pointers.Count > 0) + var pointerIndex = IndexOfPointerWithId((uint)e.Device.GetHashCode()); + if (_pointers != null && pointerIndex >= 0) { - var pointer = _pointers[0]; + var pointer = _pointers[pointerIndex]; UpdatePointerForEvent(pointer, e); - DispatchTouchEvent(TouchEventType.Move, _pointers, 0); + DispatchTouchEvent(TouchEventType.Move, _pointers, pointerIndex); } } @@ -147,13 +150,14 @@ private void OnTouchConcluded(TouchEventType touchEventType, TouchEventArgs e) private void OnPointerConcluded(TouchEventType touchEventType, MouseButtonEventArgs e) { - if (_pointers != null && _pointers.Count > 0) + var pointerIndex = IndexOfPointerWithId((uint)e.Device.GetHashCode()); + if (_pointers != null && pointerIndex >= 0) { - var pointer = _pointers[0]; + var pointer = _pointers[pointerIndex]; UpdatePointerForEvent(pointer, e); - DispatchTouchEvent(touchEventType, _pointers, 0); + DispatchTouchEvent(touchEventType, _pointers, pointerIndex); - _pointers.RemoveAt(0); + _pointers.RemoveAt(pointerIndex); if (_pointers.Count == 0) { @@ -241,24 +245,27 @@ private void UpdatePointerForEvent(ReactPointer pointer, TouchEventArgs e) { var rootPoint = e.GetTouchPoint(_view); var viewPoint = e.GetTouchPoint(pointer.ReactView); - UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint.Position); + var timestamp = e.Timestamp; + UpdatePointerForEvent(pointer, rootPoint.Position, viewPoint.Position, timestamp); } private void UpdatePointerForEvent(ReactPointer pointer, MouseButtonEventArgs e) { var rootPoint = e.GetPosition(_view); var viewPoint = e.GetPosition(pointer.ReactView); - UpdatePointerForEvent(pointer, rootPoint, viewPoint); + var timestamp = e.Timestamp; + UpdatePointerForEvent(pointer, rootPoint, viewPoint, timestamp); } private void UpdatePointerForEvent(ReactPointer pointer, MouseEventArgs e) { var rootPoint = e.GetPosition(_view); var viewPoint = e.GetPosition(pointer.ReactView); - UpdatePointerForEvent(pointer, rootPoint, viewPoint); + var timestamp = e.Timestamp; + UpdatePointerForEvent(pointer, rootPoint, viewPoint, timestamp); } - private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point viewPoint) + private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point viewPoint, int timestamp) { var positionInRoot = rootPoint; var positionInView = viewPoint; @@ -267,6 +274,7 @@ private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point pointer.PageY = (float)positionInRoot.Y; pointer.LocationX = (float)positionInView.X; pointer.LocationY = (float)positionInView.Y; + pointer.Timestamp = (ulong) timestamp; } private void DispatchTouchEvent(TouchEventType touchEventType, List activePointers, int pointerIndex)