PointerRoutedEventArgs.GetCurrentPoint method

Applies to Windows and Windows Phone

Retrieves a PointerPoint object that provides basic info on the pointer associated with the event.

Syntax


public PointerPoint GetCurrentPoint(
  UIElement relativeTo
)

Parameters

relativeTo

Type: UIElement

Any UIElement-derived object that is connected to the same object tree. To specify the object relative to the overall coordinate system, use a relativeTo value of null.

Return value

Type: PointerPoint

A PointerPoint value that represents the pointer point associated with this event. If null was passed as relativeTo, the coordinates are in the frame of reference of the overall window. If a relativeTo value other than null was passed, the coordinates are relative to the object referenced by relativeTo.

Remarks

The object retrieved by this method provides access to extended pointer info through the Properties property, which gets a PointerPointProperties object.

In the following example, we get extended pointer properties through the PointerPoint and PointerPointProperties objects. (See Quickstart: Pointers for the complete example.)


         String queryPointer(PointerPoint ptrPt)
         {
             String details = "";

             switch (ptrPt.PointerDevice.PointerDeviceType)
             {
                 case Windows.Devices.Input.PointerDeviceType.Mouse:
                     details += "\nPointer type: mouse";
                     break;
                 case Windows.Devices.Input.PointerDeviceType.Pen:
                     details += "\nPointer type: pen";
                     if (ptrPt.IsInContact)
                     {
                         details += "\nPressure: " + ptrPt.Properties.Pressure;
                         details += "\nrotation: " + ptrPt.Properties.Orientation;
                         details += "\nTilt X: " + ptrPt.Properties.XTilt;
                         details += "\nTilt Y: " + ptrPt.Properties.YTilt;
                         details += "\nBarrel button pressed: " + ptrPt.Properties.IsBarrelButtonPressed;
                     }
                     break;
                 case Windows.Devices.Input.PointerDeviceType.Touch:
                     details += "\nPointer type: touch";
                     details += "\nrotation: " + ptrPt.Properties.Orientation;
                     details += "\nTilt X: " + ptrPt.Properties.XTilt;
                     details += "\nTilt Y: " + ptrPt.Properties.YTilt;
                     break;
                 default:
                     details += "\nPointer type: n/a";
                     break;
             }

             GeneralTransform gt = Target.TransformToVisual(page);
             Point screenPoint;

             screenPoint = gt.TransformPoint(new Point(ptrPt.Position.X, ptrPt.Position.Y));
             details += "\nPointer Id: " + ptrPt.PointerId.ToString() +
                 "\nPointer location (parent): " + ptrPt.Position.X + ", " + ptrPt.Position.Y +
                 "\nPointer location (screen): " + screenPoint.X + ", " + screenPoint.Y;
             return details;
         }


Typically, the object returned by this method is used to feed pointer data to a GestureRecognizer. Another scenario is getting the MouseWheelDelta for a PointerWheelChanged event; that value is in PointerPointProperties.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Input
Windows::UI::Xaml::Input [C++]

Metadata

Windows.winmd

See also

PointerRoutedEventArgs

 

 

Show:
© 2014 Microsoft