PointerEventArgs 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
包含最后一个指针事件返回的参数。
public ref class PointerEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
class PointerEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
public sealed class PointerEventArgs
Public NotInheritable Class PointerEventArgs
- 继承
- 属性
- 实现
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
void SetWindow(CoreWindow const & window)
{
window.PointerCursor(Windows::UI::Core::CoreCursor{ CoreCursorType::Arrow, 0 });
window.PointerPressed({ this, &App::OnPointerPressed });
window.PointerReleased({ this, &App::OnPointerReleased });
window.PointerMoved({ this, &App::OnPointerMoved });
}
// Pointer event data in PointerEventArgs.
void OnPointerPressed(Windows::UI::Core::CoreWindow const& /* sender */,
Windows::UI::Core::PointerEventArgs const& /* args */) {}
void OnPointerReleased(Windows::UI::Core::CoreWindow const& /* sender */,
Windows::UI::Core::PointerEventArgs const& /* args */) {}
void OnPointerMoved(Windows::UI::Core::CoreWindow const& /* sender */,
Windows::UI::Core::PointerEventArgs const& /* args */) {}
// returning pointer events data through PointerEventArgs
void MyCoreWindowEvents::SetWindow( // implementation called by CoreApplication::Run(), provided for context
_In_ CoreWindow^ window
)
{
window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
// ...
window->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &CoreWindowEvents::OnPointerPressed);
window->PointerReleased +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &CoreWindowEvents::OnPointerReleased);
window->PointerMoved +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &CoreWindowEvents::OnPointerMoved);
// ...
}
注解
此对象由为以下事件之一注册的委托返回:
- CoreWindow.PointerCaptureLost
- CoreWindow.PointerEntered
- CoreWindow.PointerExited
- CoreWindow.PointerMoved
- CoreWindow.PointerPressed
- CoreWindow.PointerReleased
- CoreWindow.PointerWheelChanged
注意
此类不敏捷,这意味着需要考虑其线程模型和封送处理行为。 有关详细信息,请参阅 线程处理和封送处理 (C++/CX) 。
属性
CurrentPoint |
获取最后一个指针事件的指针数据。 |
Handled |
获取或设置是否已处理指针事件。 |
KeyModifiers |
获取用于修改指针输入的键盘键,例如,与另一个键一起按下时的“Ctrl”键,如 Ctrl+C。 |
方法
GetIntermediatePoints() |
检索自上次指针事件以来最多最后 64 个指针位置的指针数据。 |