Pointer Pointer Pointer Class

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

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(UIElement) and GetIntermediatePoints(UIElement) methods of PointerRoutedEventArgs. We recommend using these methods as you can specify the context of the pointer data.

The static PointerPoint methods, GetCurrentPoint(UInt32) and GetIntermediatePoints(UInt32), always use the context of the app.

Syntax

Declaration

public sealed class Pointerpublic sealed class PointerPublic NotInheritable Class Pointer

Remarks

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.

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;
        }
    }
}

Properties summary

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.

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

Gets the PointerDeviceType for the pointer device.

Gets the system-generated identifier for this pointer reference.

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 bool IsInContact { get; }public bool IsInContact { get; }Public ReadOnly Property IsInContact As boolpublic bool IsInContact { get; }

    Property Value

    • 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 bool IsInRange { get; }public bool IsInRange { get; }Public ReadOnly Property IsInRange As boolpublic bool IsInRange { get; }

    Property Value

    • 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 PointerDeviceTypepublic PointerDeviceType PointerDeviceType { get; }

    Property Value

  • PointerId
    PointerId
    PointerId
    PointerId

    Gets the system-generated identifier for this pointer reference.

    public uint PointerId { get; }public uint PointerId { get; }Public ReadOnly Property PointerId As uintpublic uint PointerId { get; }

    Property Value

    • uint
      uint
      uint

      The system-generated identifier.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Input.dll