Pointer クラス

定義

1 つのマウス、ペン/スタイラス、またはタッチ接触に関連付けられた入力ポインターの基本的なプロパティを提供します。

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」を参照)。

イベント引数でアプリに必要なポインターの詳細が本質的に公開されない場合は、PointerRoutedEventArgsGetCurrentPoint メソッドと GetIntermediatePoints メソッドを使用して拡張ポインター データにアクセスできます。 ポインター データのコンテキストを指定できるため、これらのメソッドを使用することをお勧めします。

プロパティ

IsInContact

イベントが報告された時点で、ポインター デバイスがセンサーまたはデジタイザーと接触していたかどうかを決定する値を取得します。

IsInRange

ポインター デバイスがセンサーまたはデジタイザーの検出範囲内にあるかどうかを示す値を取得します。

PointerDeviceType

ポインター デバイスの PointerDeviceType を取得します。

PointerId

このポインター参照のシステム生成識別子を取得します。

適用対象

こちらもご覧ください