PointerPoint
PointerPoint
PointerPoint
PointerPoint
Class
Definition
Provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact.
In most cases, we recommend that you obtain pointer info through the pointer event handlers of 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 expose the pointer details required by your app, you can get access to extended pointer data from the event argument through the getCurrentPoint and getIntermediatePoints methods or currentPoint and intermediatePoints properties. We recommend using the getCurrentPoint and getIntermediatePoints 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.
public : sealed class PointerPoint : IPointerPointpublic sealed class PointerPoint : IPointerPointPublic NotInheritable Class PointerPoint Implements IPointerPoint// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
In the following example, we query various pointer properties using a PointerPoint object.
// Get extended pointer data.
function queryPointer(e) {
// We get the extended pointer info through the getCurrentPoint method
// of the event argument. (We recommend using getCurrentPoint
// to ensure the coordinate space is in relation to the target.)
// Note: getCurrentPoint and currentPoint are only available in the
// local compartment, they are not available in the web compartment.
var pt = e.getCurrentPoint(e.currentTarget);
var ptTargetProperties = pt.properties;
var details = "Pointer Id: " + e.pointerId;
switch (e.pointerType) {
case "mouse":
details += "\nPointer type: mouse";
details += "\nLeft button: " + ptTargetProperties.isLeftButtonPressed;
details += "\nRight button: " + ptTargetProperties.isRightButtonPressed;
details += "\nWheel button: " + ptTargetProperties.isMiddleButtonPressed;
details += "\nX1 button: " + ptTargetProperties.isXButton1Pressed;
details += "\nX2 button: " + ptTargetProperties.isXButton2Pressed;
break;
case "pen":
details += "\nPointer type: pen";
if (pt.isInContact) {
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.tiltX;
details += "\nTilt Y: " + ptTargetProperties.tiltY;
details += "\nBarrel button pressed: " + ptTargetProperties.isBarrelButtonPressed;
}
break;
case "touch":
details += "\nPointer type: touch";
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.tiltX;
details += "\nTilt Y: " + ptTargetProperties.tiltY;
break;
default:
details += "\nPointer type: " + "n/a";
break;
}
details += "\nPointer location (target): " + e.offsetX + ", " + e.offsetY;
details += "\nPointer location (screen): " + e.screenX + ", " + e.screenY;
return details;
}
// Get extended pointer data.
function queryPointer(e) {
// We get the extended pointer info through the getCurrentPoint method
// of the event argument. (We recommend using getCurrentPoint
// to ensure the coordinate space is in relation to the target.)
// Note: getCurrentPoint and currentPoint are only available in the
// local compartment, they are not available in the web compartment.
var pt = e.getCurrentPoint(e.currentTarget);
var ptTargetProperties = pt.properties;
var details = "Pointer Id: " + e.pointerId;
switch (e.pointerType) {
case "mouse":
details += "\nPointer type: mouse";
details += "\nLeft button: " + ptTargetProperties.isLeftButtonPressed;
details += "\nRight button: " + ptTargetProperties.isRightButtonPressed;
details += "\nWheel button: " + ptTargetProperties.isMiddleButtonPressed;
details += "\nX1 button: " + ptTargetProperties.isXButton1Pressed;
details += "\nX2 button: " + ptTargetProperties.isXButton2Pressed;
break;
case "pen":
details += "\nPointer type: pen";
if (pt.isInContact) {
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.tiltX;
details += "\nTilt Y: " + ptTargetProperties.tiltY;
details += "\nBarrel button pressed: " + ptTargetProperties.isBarrelButtonPressed;
}
break;
case "touch":
details += "\nPointer type: touch";
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.tiltX;
details += "\nTilt Y: " + ptTargetProperties.tiltY;
break;
default:
details += "\nPointer type: " + "n/a";
break;
}
details += "\nPointer location (target): " + e.offsetX + ", " + e.offsetY;
details += "\nPointer location (screen): " + e.screenX + ", " + e.screenY;
return details;
}
function queryPointer(e) {
/// <summary>
/// Get extended pointer data.
/// </summary>
/// <param name="e" type="Event">The event argument.</param>
// We get the extended pointer info through the getCurrentPoint method
// of the event argument. (We recommend using getCurrentPoint
// to ensure the coordinate space is in relation to the target.)
// Note: getCurrentPoint and currentPoint are only available in the
// local compartment, they are not available in the web compartment.
var pt = e.getCurrentPoint(e.currentTarget);
var ptTargetProperties = pt.properties;
var details = "Pointer Id: " + e.pointerId;
switch (e.pointerType) {
case "mouse":
details += "\nPointer type: mouse";
details += "\nLeft button: " + ptTargetProperties.isLeftButtonPressed;
details += "\nRight button: " + ptTargetProperties.isRightButtonPressed;
details += "\nWheel button: " + ptTargetProperties.isMiddleButtonPressed;
details += "\nX1 button: " + ptTargetProperties.isXButton1Pressed;
details += "\nX2 button: " + ptTargetProperties.isXButton2Pressed;
break;
case "pen":
details += "\nPointer type: pen";
if (pt.isInContact) {
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.xtilt;
details += "\nTilt Y: " + ptTargetProperties.ytilt;
details += "\nBarrel button pressed: " + ptTargetProperties.isBarrelButtonPressed;
}
break;
case "touch":
details += "\nPointer type: touch";
details += "\nPressure: " + ptTargetProperties.pressure;
details += "\nrotation: " + ptTargetProperties.rotation;
details += "\nTilt X: " + ptTargetProperties.xtilt;
details += "\nTilt Y: " + ptTargetProperties.ytilt;
break;
default:
details += "\nPointer type: " + "n/a";
break;
}
details += "\nPointer location (target): " + e.offsetX + ", " + e.offsetY;
details += "\nPointer location (screen): " + e.screenX + ", " + e.screenY;
return details;
}
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;
}
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;
}
Remarks
The PointerPoint class implements IPointerPoint.
See PointerPointProperties for extended properties accessible through Properties.
Note
: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Properties
FrameId FrameId FrameId FrameId
Gets the ID of an input frame.
public : unsigned int FrameId { get; }public uint FrameId { get; }Public ReadOnly Property FrameId As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The frame ID.
Remarks
A frame is a collection of input points at a specific instance in time. The frame ID is a common identifier for each input point in the collection.
IsInContact IsInContact IsInContact IsInContact
Gets a value that indicates whether the physical entity (touch, pen/stylus, or mouse button) is pressed down.
public : PlatForm::Boolean IsInContact { get; }public bool IsInContact { get; }Public ReadOnly Property IsInContact As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean bool bool bool
True if pressed down; false otherwise.
PointerDevice PointerDevice PointerDevice PointerDevice
Gets information about the device associated with the input pointer.
public : PointerDevice PointerDevice { get; }public PointerDevice PointerDevice { get; }Public ReadOnly Property PointerDevice As PointerDevice// You can use this property in JavaScript.
The input device.
PointerId PointerId PointerId PointerId
Gets a unique identifier for the input pointer.
public : unsigned int PointerId { get; }public uint PointerId { get; }Public ReadOnly Property PointerId As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
A unique value that identifies the input pointer.
Position Position Position Position
Gets the location of the pointer input in client coordinates.
public : Point Position { get; }public Point Position { get; }Public ReadOnly Property Position As Point// You can use this property in JavaScript.
Remarks
Position contains the client coordinates of the pointer input as interpreted by the system. Under some circumstances, such as input prediction, this data can be modified by the system to compensate for hardware latency or message latency due to inherent delays in sensing and processing the pointer location on the digitizer.
See RawPosition for information on handling raw input data.
- See Also
Properties Properties Properties Properties
Gets extended information about the input pointer.
public : PointerPointProperties Properties { get; }public PointerPointProperties Properties { get; }Public ReadOnly Property Properties As PointerPointProperties// You can use this property in JavaScript.
The extended properties exposed by the input device.
RawPosition RawPosition RawPosition RawPosition
Gets the raw location of the pointer input in client coordinates.
public : Point RawPosition { get; }public Point RawPosition { get; }Public ReadOnly Property RawPosition As Point// You can use this property in JavaScript.
Remarks
RawPosition contains the client coordinates of the input pointer as reported by the input device. Under some circumstances, such as input prediction, this data can be modified by the system to compensate for hardware latency or message latency due to inherent delays in sensing and processing the pointer location on the digitizer.
See Position for more information on handling modified input data.
- See Also
Timestamp Timestamp Timestamp Timestamp
Gets the time when the input occurred.
public : ulong Timestamp { get; }public ulong Timestamp { get; }Public ReadOnly Property Timestamp As ulong// You can use this property in JavaScript.
- Value
- ulong ulong ulong ulong
The time, relative to the system boot time, in microseconds.
Methods
GetCurrentPoint(UInt32) GetCurrentPoint(UInt32) GetCurrentPoint(UInt32) GetCurrentPoint(UInt32)
Retrieves position and state information for the specified pointer.
In most cases, we recommend that you obtain pointer info through the pointer event handlers of 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 expose the pointer details required by your app, you can get access to extended pointer data from the event argument through the getCurrentPoint and getIntermediatePoints methods or currentPoint and intermediatePoints properties. We recommend using the getCurrentPoint and getIntermediatePoints 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.
public : static PointerPoint GetCurrentPoint(unsigned int pointerId)public static PointerPoint GetCurrentPoint(UInt32 pointerId)Public Static Function GetCurrentPoint(pointerId As UInt32) As PointerPoint// You can use this method in JavaScript.
- pointerId
- unsigned int UInt32 UInt32 UInt32
The ID of the pointer.
The pointer property values.
Remarks
GetCurrentPoint is a static method.
- See Also
GetCurrentPoint(UInt32, IPointerPointTransform) GetCurrentPoint(UInt32, IPointerPointTransform) GetCurrentPoint(UInt32, IPointerPointTransform) GetCurrentPoint(UInt32, IPointerPointTransform)
Retrieves the transformed information for the specified pointer.
In most cases, we recommend that you obtain pointer info through the pointer event handlers of 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 expose the pointer details required by your app, you can get access to extended pointer data from the event argument through the getCurrentPoint and getIntermediatePoints methods or currentPoint and intermediatePoints properties. We recommend using the getCurrentPoint and getIntermediatePoints 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.
public : static PointerPoint GetCurrentPoint(unsigned int pointerId, IPointerPointTransform transform)public static PointerPoint GetCurrentPoint(UInt32 pointerId, IPointerPointTransform transform)Public Static Function GetCurrentPoint(pointerId As UInt32, transform As IPointerPointTransform) As PointerPoint// You can use this method in JavaScript.
- pointerId
- unsigned int UInt32 UInt32 UInt32
The ID of the pointer.
- transform
- IPointerPointTransform IPointerPointTransform IPointerPointTransform IPointerPointTransform
The transform to apply to the pointer.
The pointer property values.
Remarks
GetCurrentPoint is a static method.
This method is useful for getting pointer information relative to a specific element.
- See Also
GetIntermediatePoints(UInt32) GetIntermediatePoints(UInt32) GetIntermediatePoints(UInt32) GetIntermediatePoints(UInt32)
Retrieves position and state information for the specified pointer, from the last pointer event up to and including the current pointer event.
In most cases, we recommend that you obtain pointer info through the pointer event handlers of 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 expose the pointer details required by your app, you can get access to extended pointer data from the event argument through the getCurrentPoint and getIntermediatePoints methods or currentPoint and intermediatePoints properties. We recommend using the getCurrentPoint and getIntermediatePoints 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.
public : static IVector<PointerPoint> GetIntermediatePoints(unsigned int pointerId)public static IList<PointerPoint> GetIntermediatePoints(UInt32 pointerId)Public Static Function GetIntermediatePoints(pointerId As UInt32) As IList( Of PointerPoint )// You can use this method in JavaScript.
- pointerId
- unsigned int UInt32 UInt32 UInt32
The ID of the pointer.
The transformed pointer properties (current and historic).
Remarks
GetIntermediatePoints is a static method.
The most recent pointer information retrieved by this method is equivalent to that retrieved by the GetCurrentPoint method.
- See Also
GetIntermediatePoints(UInt32, IPointerPointTransform) GetIntermediatePoints(UInt32, IPointerPointTransform) GetIntermediatePoints(UInt32, IPointerPointTransform) GetIntermediatePoints(UInt32, IPointerPointTransform)
Retrieves the transformed position and state information for the specified pointer, from the last pointer event up to and including the current pointer event.
In most cases, we recommend that you obtain pointer info through the pointer event handlers of 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 expose the pointer details required by your app, you can get access to extended pointer data from the event argument through the getCurrentPoint and getIntermediatePoints methods or currentPoint and intermediatePoints properties. We recommend using the getCurrentPoint and getIntermediatePoints 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.
public : static IVector<PointerPoint> GetIntermediatePoints(unsigned int pointerId, IPointerPointTransform transform)public static IList<PointerPoint> GetIntermediatePoints(UInt32 pointerId, IPointerPointTransform transform)Public Static Function GetIntermediatePoints(pointerId As UInt32, transform As IPointerPointTransform) As IList( Of PointerPoint )// You can use this method in JavaScript.
- pointerId
- unsigned int UInt32 UInt32 UInt32
The ID of the pointer.
- transform
- IPointerPointTransform IPointerPointTransform IPointerPointTransform IPointerPointTransform
The transform to apply to the pointer.
The transformed pointer properties (current and historic).
Remarks
GetIntermediatePoints is a static method.
This method is useful for getting pointer information relative to a specific element.
The most recent pointer information retrieved by this method is equivalent to that retrieved by the GetCurrentPoint method.
- See Also
See Also
- Custom user interactions
- UX guidelines for custom user interactions
- Touch design guidelines
- User interaction mode sample
- Focus visuals sample
- Input: Device capabilities sample
- Input: Ink sample
- Input: Manipulations and gestures (JavaScript) sample
- Input: Simplified ink sample
- Input: Windows 8 gestures sample
- Input: XAML user input events sample
- XAML scrolling, panning, and zooming sample
- DirectX touch input sample
- Input: Manipulations and gestures (C++) sample
- Input: Touch hit testing sample
- Input source identification sample
- Touch injection sample
- Win32 touch hit-testing sample
- Basic input sample (Windows 10)