Pointer 클래스

정의

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

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

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 코드 예제에서는 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;
        }
    }
}

설명

대부분의 경우 선택한 언어 프레임워크에서 포인터 이벤트 처리기의 이벤트 인수를 통해 포인터 정보를 가져오는 것이 좋습니다(JavaScript를 사용하는 Windows 앱, C++, C#또는 Visual Basic을 사용하는 UWP 앱 또는 C++와 함께 DirectX를 사용하는 UWP 앱).

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

정적 PointerPoint 메서드인 GetCurrentPointGetIntermediatePoints는 항상 앱의 컨텍스트를 사용합니다. 포인터는 입력 디바이스를 설명하는 데 사용되는 추상 클래스입니다. 이 클래스는 발생하는 각 포인터 이벤트에 대한 입력 디바이스(예: 스타일러스, 손가락 또는 마우스)를 식별합니다.

속성

IsInContact

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

IsInRange

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

PointerDeviceType

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

PointerId

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

적용 대상

추가 정보