Pointer 클래스

정의

단일 마우스, 펜/스타일러스 또는 터치 접점과 연결된 입력 포인터에 대한 기본 속성을 제공합니다.

public ref class Pointer sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class Pointer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class Pointer
Public NotInheritable Class Pointer
상속
Object Platform::Object IInspectable Pointer
특성

예제

다음 코드 예제에서는 Pointer 클래스를 사용하여 앱에서 각 입력 연락처의 고유한 PointerId 를 찾고, PointerDeviceType 을 사용하여 특정 형식의 입력(예: 마우스 입력)을 무시하고 포인터 위치를 저장하는 방법을 보여 줍니다. Pointer 클래스를 사용하는 추가 코드는 입력 샘플을 참조하세요.

using System.Collections.Generic;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;

namespace PointerExample
{
    public sealed partial class BlankPage : Page
    {
        Dictionary<uint, Point?> _contacts;
        const uint SUPPORTEDCONTACTS = 5;

        public BlankPage()
        {
            this.InitializeComponent();
            _contacts = new Dictionary<uint, Point?>((int)SUPPORTEDCONTACTS);
            this.PointerPressed += BlankPage_PointerPressed;
            this.PointerReleased += BlankPage_PointerReleased;
        }

        private void BlankPage_PointerPressed(object sender, 
            PointerRoutedEventArgs e)
        {
            // Ignore mouse inputs. 
            if (e.Pointer.PointerDeviceType != 
                Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // Store and touch input contacts.  
                Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this);
                _contacts[e.Pointer.PointerId] = pt.Position;
            }
            e.Handled = true;
        }

        private void BlankPage_PointerReleased(object sender, 
            PointerRoutedEventArgs e)
        {
            // Ignore mouse inputs.
            if (e.Pointer.PointerDeviceType != 
                Windows.Devices.Input.PointerDeviceType.Mouse)
            {
                // Remove pointer contacts information.
                uint ptrId = e.Pointer.PointerId;
                if (_contacts.ContainsKey(ptrId))
                {
                    _contacts[ptrId] = null;
                    _contacts.Remove(ptrId);
                }
            }
            e.Handled = true;
        }
    }
}

설명

클래스는 Pointer 입력 디바이스를 설명하는 데 사용됩니다. 이 클래스는 발생하는 각 포인터 이벤트에 대한 입력 디바이스(예: 스타일러스, 손가락 또는 마우스)를 식별합니다.

대부분의 경우 포인터 이벤트 처리기의 이벤트 인수를 통해 포인터 정보를 가져오는 것이 좋습니다( PointerRoutedEventArgs 참조).

이벤트 인수가 앱에 필요한 포인터 세부 정보를 기본적으로 노출하지 않는 경우 PointerRoutedEventArgsGetCurrentPointGetIntermediatePoints 메서드를 통해 확장 포인터 데이터에 액세스할 수 있습니다. 포인터 데이터의 컨텍스트를 지정할 수 있으므로 이러한 메서드를 사용하는 것이 좋습니다.

속성

IsInContact

이벤트가 보고되었을 때 포인터 디바이스가 센서 또는 디지타이저와 접촉했는지 여부를 결정하는 값을 가져옵니다.

IsInRange

포인터 디바이스가 센서 또는 디지타이저의 검색 범위 내에 있는지 여부를 나타내는 값을 가져옵니다.

PointerDeviceType

포인터 디바이스에 대한 PointerDeviceType 을 가져옵니다.

PointerId

이 포인터 참조에 대한 시스템 생성 식별자를 가져옵니다.

적용 대상

추가 정보