Pointer Pointer Pointer Pointer Class

Definition

Provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact.

public : sealed class Pointer : IPointerpublic sealed class Pointer : IPointerPublic NotInheritable Class Pointer Implements IPointer// This API is not available in Javascript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following code example shows the usage of Pointer class to find the unique PointerId of each input contact in an app, use the PointerDeviceType to ignore specific forms of input (for example, mouse input) and store the Pointer positions. For additional code that uses the Pointer class, see the Input sample.

using System.Collections.Generic;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;

namespace PointerExample
{
    public sealed partial class BlankPage : Page
    {
        Dictionary<uint, Point?> _contacts;
        const uint SUPPORTEDCONTACTS = 5;

        public BlankPage()
        {
            this.InitializeComponent();
            _contacts = new Dictionary<uint, Point?>((int)SUPPORTEDCONTACTS);
            this.PointerPressed += BlankPage_PointerPressed;
            this.PointerReleased += BlankPage_PointerReleased;
        }

        private void BlankPage_PointerPressed(object sender, 
            PointerRoutedEventArgs e)
        {
            // Ignore mouse inputs. 
            if (e.Pointer.PointerDeviceType != 
                Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // Store and and touch input contacts.  
                Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this);
                _contacts[e.Pointer.PointerId] = pt.Position;
            }
            e.Handled = true;
        }

        private void BlankPage_PointerReleased(object sender, 
            PointerRoutedEventArgs e)
        {
            // Ignore mouse inputs.
            if (e.Pointer.PointerDeviceType != 
                Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // Remove pointer contacts information.
                uint ptrId = e.Pointer.PointerId;
                if (_contacts.ContainsKey(ptrId))
                {
                    _contacts[ptrId] = null;
                    _contacts.Remove(ptrId);
                }
            }
            e.Handled = true;
        }
    }
}

Remarks

In most cases, we recommend that you get pointer info through the event argument of the pointer event handlers in your chosen Windows 8 language framework (Windows app using JavaScript, Windows Store app using C++, C#, or Visual Basic, or Windows Store app using DirectX with C++).

If the event argument doesn't intrinsically expose the pointer details required by your app, you can get access to extended pointer data through the GetCurrentPoint and GetIntermediatePoints methods of PointerRoutedEventArgs. We recommend using these methods as you can specify the context of the pointer data.

The static PointerPoint methods, GetCurrentPoint and GetIntermediatePoints, always use the context of the app. Pointer is an abstract class that is used to describe an input device. This class identifies the input device (such as stylus, finger, or mouse) for each pointer event that occurs.

Properties

IsInContact IsInContact IsInContact IsInContact

Gets a value that determines whether the pointer device was in contact with a sensor or digitizer at the time that the event was reported.

public : PlatForm::Boolean IsInContact { get; }public bool IsInContact { get; }Public ReadOnly Property IsInContact As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

true if the pointer device was in contact; otherwise, false.

IsInRange IsInRange IsInRange IsInRange

Gets a value that indicates whether the pointer device is within detection range of a sensor or digitizer.

public : PlatForm::Boolean IsInRange { get; }public bool IsInRange { get; }Public ReadOnly Property IsInRange As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

true if touch or pen is within detection range or mouse is over; otherwise false

Remarks

A pointer comes into existence when the pointer device enters detection range and is canceled when the pointer device leaves detection range.

PointerDeviceType PointerDeviceType PointerDeviceType PointerDeviceType

Gets the PointerDeviceType for the pointer device.

public : PointerDeviceType PointerDeviceType { get; }public PointerDeviceType PointerDeviceType { get; }Public ReadOnly Property PointerDeviceType As PointerDeviceType// This API is not available in Javascript.

PointerId PointerId PointerId PointerId

Gets the system-generated identifier for this pointer reference.

public : unsigned int PointerId { get; }public uint PointerId { get; }Public ReadOnly Property PointerId As uint// This API is not available in Javascript.
Value
unsigned int uint uint uint

The system-generated identifier.

See Also