UIElement.PointerMoved 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
포인터가 이 요소의 적중 테스트 영역 내에 남아 있는 동안 포인터가 움직일 때 발생합니다.
UWP에 해당하는 WinUI 2 API: Microsoft.UI.Xaml.UIElement.PointerMoved(Windows 앱 SDK WinUI의 경우 Windows 앱 SDK 네임스페이스 참조).
public:
virtual event PointerEventHandler ^ PointerMoved;
// Register
event_token PointerMoved(PointerEventHandler const& handler) const;
// Revoke with event_token
void PointerMoved(event_token const* cookie) const;
// Revoke with event_revoker
UIElement::PointerMoved_revoker PointerMoved(auto_revoke_t, PointerEventHandler const& handler) const;
public event PointerEventHandler PointerMoved;
function onPointerMoved(eventArgs) { /* Your code */ }
uIElement.addEventListener("pointermoved", onPointerMoved);
uIElement.removeEventListener("pointermoved", onPointerMoved);
- or -
uIElement.onpointermoved = onPointerMoved;
Public Custom Event PointerMoved As PointerEventHandler
<uiElement PointerMoved="eventhandler"/>
이벤트 유형
설명
터치, 마우스 및 펜/스타일러스 상호 작용은 UWP 앱에서 포인터 입력으로 수신, 처리 및 관리됩니다. 이러한 상호 작용은 PointerMoved 이벤트를 생성할 수 있습니다. 자세한 내용은 이 항목의 포인터 입력 처리 및 "마우스 및 스타일러스 입력에 대한 PointerMoved" 섹션을 참조하세요.
일부 UI 시나리오에서는 특히 사용자가 마우스를 사용하는 경우 이 이벤트가 많이 발생합니다. 이 처리기에 입력한 코드의 성능 프로필에 유의하고 논리를 실제로 실행해야 하는 횟수를 제한할 수 있는 고유한 플래그 또는 허용 오차를 사용하는 방법을 고려합니다.
이 이벤트는 라우트된 이벤트입니다. 라우트된 이벤트 개념에 대한 자세한 내용은 이벤트 및 라우트된 이벤트 개요를 참조하세요.
터치 동작의 경우와 터치 동작의 결과인 조작 관련 또는 조작 이벤트의 경우에도 이벤트 원본이 되거나 터치 동작과 연관된 이벤트를 실행하려면 요소의 적중 횟수 테스트가 보여야 합니다. UIElement.Visibility는 Visible여야 합니다. 파생 형식의 다른 속성도 적중 테스트 표시 유형에 영향을 미칩니다. 자세한 내용은 이벤트 및 라우트된 이벤트 개요를 참조하세요.
또한 이 이벤트는 이벤트에 대한 이벤트 데이터가 처리됨으로 표시된 경우에도 호출되는 경로에 이벤트 처리기를 연결하는 기능을 지원 합니다. AddHandler을 참조하세요.
마우스 및 스타일러스 입력에 대한 PointerMoved
마우스 입력 장치에는 마우스가 요소의 경계를 넘어 이동할 때마다 마우스 단추를 누르지 않더라도 표시되는 화면 커서가 있습니다. 유사한 동작은 펜 디바이스 입력에 사용할 수 있습니다. 여기서 입력 디바이스는 펜이 입력 장치 표면 바로 위에 마우스를 가져가고 있지만 만지지 않는 것을 감지할 수 있습니다. 따라서 마우스 및 펜 입력은 터치 입력보다 PointerMoved 이벤트를 더 자주 발생합니다. 자세한 내용은 마우스 조작을 참조하세요.
반대로 터치 포인트는 손가락이 표면에 닿는 경우에만 감지할 수 있습니다. 터치 포인트는 포인터가 움직일 때 터치 포인트가 표면과 지속적으로 접촉하는 동안에만 PointerMoved를 생성합니다. PointerMoved를 생성하는 이러한 종류의 터치 작업의 경우 동작이 조작 또는 제스처로 처리될 가능성이 높습니다. 자세한 내용은 포인터 입력 처리를 참조하세요.
마우스 입력은 마우스 입력이 처음 검색될 때 할당된 단일 포인터와 연결되며, 마우스 시작 상호 작용은 모두 동일합니다 PointerId. 마우스 단추(왼쪽, 휠 또는 오른쪽)를 클릭하면 이벤트를 통해 PointerPressed 포인터와 해당 단추 간에 보조 연결이 만들어집니다. 이 PointerReleased 이벤트는 동일한 마우스 단추가 해제된 경우에만 발생합니다(이 이벤트가 완료될 때까지 다른 단추는 포인터와 연결할 수 없음). 이 독점적인 연결 때문에 다른 마우스 단추 클릭은 PointerMoved 이벤트를 통해 라우트됩니다. 이 예제와 같이 이 이벤트를 처리할 때 마우스 단추 상태를 테스트할 수 있습니다.
private void Target_PointerMoved(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
// Multiple, simultaneous mouse button inputs are processed here.
// Mouse input is associated with a single pointer assigned when
// mouse input is first detected.
// Clicking additional mouse buttons (left, wheel, or right) during
// the interaction creates secondary associations between those buttons
// and the pointer through the pointer pressed event.
// The pointer released event is fired only when the last mouse button
// associated with the interaction (not necessarily the initial button)
// is released.
// Because of this exclusive association, other mouse button clicks are
// routed through the pointer move event.
if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
// To get mouse state, we need extended pointer details.
// We get the pointer info through the getCurrentPoint method
// of the event argument.
Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(Target);
if (ptrPt.Properties.IsLeftButtonPressed)
{
eventLog.Text += "\nLeft button: " + ptrPt.PointerId;
}
if (ptrPt.Properties.IsMiddleButtonPressed)
{
eventLog.Text += "\nWheel button: " + ptrPt.PointerId;
}
if (ptrPt.Properties.IsRightButtonPressed)
{
eventLog.Text += "\nRight button: " + ptrPt.PointerId;
}
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
// Display pointer details.
updateInfoPop(e);
}
private void Target_PointerMoved(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
// Multiple, simultaneous mouse button inputs are processed here.
// Mouse input is associated with a single pointer assigned when
// mouse input is first detected.
// Clicking additional mouse buttons (left, wheel, or right) during
// the interaction creates secondary associations between those buttons
// and the pointer through the pointer pressed event.
// The pointer released event is fired only when the last mouse button
// associated with the interaction (not necessarily the initial button)
// is released.
// Because of this exclusive association, other mouse button clicks are
// routed through the pointer move event.
if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
// To get mouse state, we need extended pointer details.
// We get the pointer info through the getCurrentPoint method
// of the event argument.
Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(Target);
if (ptrPt.Properties.IsLeftButtonPressed)
{
eventLog.Text += "\nLeft button: " + ptrPt.PointerId;
}
if (ptrPt.Properties.IsMiddleButtonPressed)
{
eventLog.Text += "\nWheel button: " + ptrPt.PointerId;
}
if (ptrPt.Properties.IsRightButtonPressed)
{
eventLog.Text += "\nRight button: " + ptrPt.PointerId;
}
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
// Display pointer details.
updateInfoPop(e);
}
게임과 같은 일부 애플리케이션은 특정 기능(예: 가상 트랙볼 또는 보기 카메라)에 대한 상대 마우스 움직임을 추적해야 하며 시스템 커서 또는 절대 화면 좌표를 사용하지 않습니다. 마우스 커서를 숨기고 절대 마우스 데이터를 무시하는 방법에 대한 자세한 내용은 상대 마우스 이동 및 CoreWindow를 참조하세요.
적용 대상
추가 정보
피드백
다음에 대한 사용자 의견 제출 및 보기