Skip to content
Merged
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
15 changes: 14 additions & 1 deletion ReactWindows/ReactNative.Net46/Touch/TouchHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ReactNative.UIManager;
using ReactNative.UIManager.Events;
Expand Down Expand Up @@ -299,6 +299,10 @@ private void UpdatePointerForEvent(ReactPointer pointer, Point rootPoint, Point
pointer.LocationX = (float)positionInView.X;
pointer.LocationY = (float)positionInView.Y;
pointer.Timestamp = (ulong) timestamp;

pointer.ShiftKey = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
pointer.AltKey = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
pointer.CtrlKey = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
}

private void DispatchTouchEvent(TouchEventType touchEventType, List<ReactPointer> activePointers, int pointerIndex)
Expand Down Expand Up @@ -510,6 +514,15 @@ class ReactPointer

[JsonProperty(PropertyName = "isEraser", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool IsEraser { get; set; }

[JsonProperty(PropertyName = "shiftKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool ShiftKey { get; set; }

[JsonProperty(PropertyName = "ctrlKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool CtrlKey { get; set; }

[JsonProperty(PropertyName = "altKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool AltKey { get; set; }
}
}
}
14 changes: 14 additions & 0 deletions ReactWindows/ReactNative/Touch/TouchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.Graphics.Display;
using Windows.UI.Core;
using Windows.UI.Input;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -231,6 +232,10 @@ private void UpdatePointerForEvent(ReactPointer pointer, PointerPoint rootPoint,
pointer.Timestamp = rootPoint.Timestamp / 1000; // Convert microseconds to milliseconds;
pointer.Force = rootPoint.Properties.Pressure;
pointer.IsBarrelButtonPressed = rootPoint.Properties.IsBarrelButtonPressed;

pointer.ShiftKey = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
pointer.AltKey = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down);
pointer.CtrlKey = Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to implement this key or add an API for core window keyboard events to JavaScript? I guess the concern with doing it in JavaScript is that it's asynchronous (something could get out of sync between the keyboard state and the click event)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I followed the "stamp the modifier keys at event creation moment" pattern.
If by API you mean a notification pipe from native to JS that keeps some JS state in sync with the kbd state, I just didn't think the complexity would warrant the perf gain.


In reply to: 172177315 [](ancestors = 172177315)


private void DispatchTouchEvent(TouchEventType touchEventType, List<ReactPointer> activePointers, int pointerIndex)
Expand Down Expand Up @@ -480,6 +485,15 @@ class ReactPointer

[JsonProperty(PropertyName = "isEraser", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool IsEraser { get; set; }

[JsonProperty(PropertyName = "shiftKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool ShiftKey { get; set; }

[JsonProperty(PropertyName = "ctrlKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool CtrlKey { get; set; }

[JsonProperty(PropertyName = "altKey", DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool AltKey { get; set; }
}
}
}