Pen interaction improvements in Windows 10 Insider Preview Build 16215
With the Windows 10 Fall, or Autumn, or Season Between Summer and Winter, or Winter Is Coming, Creator’s Update (BTW, sorry southern hemisphere, maybe next time), Microsoft is making some subtle, but important, changes to provide users with a more intuitive and self-contained pen interaction experience for non-inking scenarios.
In this update, the pen experience has been improved in two primary areas: scrolling/panning and text selection.
Previously, text selection was the default experience when using a pen with non-inking controls and content. Because direct manipulation of the UI was not supported, a pen user had to switch to touch or another device (such as mouse or touchpad), or hunt and peck for a scrollbar to move around within a scrolling area. Now, scrolling is the default pen behavior, which is more closely aligned to the established touch experience everyone is familiar with and minimizes, or eliminates in many cases, the often awkward pas de deux of input devices.
With this change in the default pen behavior, text selection with a pen also had to be refined. Users must now press the pen barrel button to override the scrolling behavior and perform text selection. By dragging the pen while the barrel button is pressed, users can quickly select content such as text, ink, and other objects (selection grippers are also provided for the highlighted content).
While these changes don’t spell the end of the line for other input devices, Microsoft would love to see more people using the pen across devices and platforms. This is just another way the overall Windows experience is being refined to provide the best experience for all our users.
For developers
To support this new behavior, the ScrollViewer control consumes pointer events unless you specify otherwise.
If your app must support the previous default pen behavior, you can override the new scrolling behavior and revert to the previous behavior. To do this, just handle the PointerPressed event and set the ManipulationMode property to specify that the system should not handle pen interaction to scroll your main ScrollViewer. You also handle the PointerReleased and PointerCanceled events to turn the default system behavior back on when the Pen is removed.
This example shows how to:
- Register the events using the AddHandler method with the handledEventsToo parameter set to true.
- Check if the pointer device is a Pen.
- In the PointerPressed event handler, turn off system manipulation support in the ScrollViewer.
- In the PointerReleased and PointerCanceled event handlers, turn system manipulation support back on.
XAML<Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”>
<ScrollViewer x:Name=”myScrollViewer”>
<Image Source=”Assets/StoreLogo.png”/>
</ScrollViewer>
</Grid>C#public MainPage()
{
this.InitializeComponent();
this.myScrollViewer.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(myScrollViewer_PointerPressed), true /*handledEventsToo*/);
this.myScrollViewer.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(myScrollViewer_PointerReleased), true /*handledEventsToo*/);
this.myScrollViewer.AddHandler(UIElement.PointerCanceledEvent, new PointerEventHandler(myScrollViewer_PointerCanceled), true /*handledEventsToo*/);
}private void myScrollViewer_PointerPressed(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
{
(myScrollViewer.Content as UIElement).ManipulationMode &= ~ManipulationModes.System;
}
}private void myScrollViewer_PointerReleased(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
{
(myScrollViewer.Content as UIElement).ManipulationMode |= ManipulationModes.System;
}
}private void myScrollViewer_PointerCanceled(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
{
(myScrollViewer.Content as UIElement).ManipulationMode |= ManipulationModes.System;
}
}
These subtle, yet important, improvements to the Windows pen interaction experience should provide users with a more consistent overall experience regardless of the input device they’re using.
Thanks for taking the time to read this post!
For more details, see the following articles on the Windows Dev Center:
