导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

PointerPoint Class

为单个鼠标、钢笔/触笔或触摸触点提供基本属性。

在大多数情况下,我们建议您通过您选择的 Windows 8 语言框架(使用 JavaScript 的 Windows 应用商店应用程序、使用 C++、C# 或 Visual Basic 的 Windows 应用商店应用程序,或使用 DirectX 与 C++ 的 Windows 应用商店应用程序)的指针事件处理程序获取指针信息。

如果事件参数不公开您的应用程序所需的指针详细信息,则可以通过 getCurrentPointgetIntermediatePoints 方法或 currentPointintermediatePoints 属性从事件参数中获取对扩展指针数据的访问权限。建议使用 getCurrentPointgetIntermediatePoints 方法,因为这样您可以指定指针数据的上下文。

静态 PointerPoint 方法 GetCurrentPointGetIntermediatePoints 始终使用该应用程序的上下文。

语法


var pointerPoint = Windows.UI.Input.PointerPoint;

特性

[MarshalingBehavior(None)]
[Version(0x06020000)]

成员

PointerPoint类 具有这些类型的成员:

方法

The PointerPoint 类 具有这些方法。 对于 C#、Visual Basic 和 C++,它还继承方法于Object 类.

方法说明
GetCurrentPoint(UInt32) Retrieves position and state information for the specified pointer.
GetCurrentPoint(UInt32, IPointerPointTransform) Retrieves the transformed information for the specified pointer.
GetIntermediatePoints(UInt32) Retrieves position and state information for the specified pointer, from the last pointer event up to and including the current pointer event.
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.

 

属性

PointerPoint类 具有这些属性。

属性访问类型说明

FrameId

只读Gets the ID of an input frame.

IsInContact

只读Gets a value that indicates whether the physical entity (touch, pen/stylus, or mouse button) is pressed down.

PointerDevice

只读Gets information about the device associated with the input pointer.

PointerId

只读Gets a unique identifier for the input pointer.

Position

只读Gets the location of the pointer input in client coordinates.

Properties

只读Gets extended information about the input pointer.

RawPosition

只读Gets the raw location of the pointer input in client coordinates.

Timestamp

只读Gets the time when the input occurred.

 

备注

PointerPoint 类实现 IPointerPoint。

请参见 PointerPointProperties 了解可通过 Properties 访问的扩展属性。

注意  :此类不敏捷,这意味着您需要考虑其线程模型和封送行为。有关更多信息,请参见线程处理和封送处理 (C++/CX)在多线程环境中使用 Windows 运行时对象 (.NET)

示例

在以下示例中,我们使用 PointerPoint 对象查询各种指针属性。


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


要求

最低支持客户端

Windows 8 [仅 Windows 应用商店应用程序]

最低支持服务器

Windows Server 2012 [仅 Windows 应用商店应用程序]

最低支持电话

Windows Phone 8

命名空间

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

元数据

Windows.winmd

另请参见

引用
Windows.UI.Input 类
Windows.Devices.Input
Windows.UI.Core
Windows.UI.Input
Windows.UI.Input.Inking
Windows.UI.Xaml.Input
TypedEventHandler
概念
响应用户交互
常见用户交互准则
开发 Windows 应用商店应用(JavaScript 和 HTML)
使用在 JavaScript 上的 Windows 运行时
触控交互模型
示例 (DOM)
HTML 滚动、平移和缩放示例
输入:DOM 指针事件处理示例
输入:可实例化笔势示例
示例(Windows 应用商店应用  API)
输入:设备功能示例
输入:墨迹示例
输入:操作和笔势 (JavaScript) 示例
输入:简化墨迹示例
输入:Windows 8 笔势示例
输入:XAML 用户输入事件示例
XAML 滚动、平移和缩放示例
示例 (DirectX)
DirectX 触控输入示例
输入:操作和笔势 (C++) 示例
输入:触控命中测试示例
示例(Win32/桌面)
输入源标识示例
触摸注入示例
Win32 触控命中测试示例

 

 

显示:
© 2014 Microsoft