VisualInteractionSource.TryRedirectForManipulation メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オーバーロード
TryRedirectForManipulation(ExpPointerPoint) | |
TryRedirectForManipulation(PointerPoint) |
特定のポインター ストリームに対して構成された操作を、指定された PointerPoint から開始して、アプリの UI スレッドではなく InteractionTracker に送信しようとします。 重要 このメソッドは、 Touch の PointerDeviceType でのみ呼び出す必要があります。 |
TryRedirectForManipulation(ExpPointerPoint)
public:
virtual void TryRedirectForManipulation(ExpPointerPoint ^ pointerPoint) = TryRedirectForManipulation;
void TryRedirectForManipulation(ExpPointerPoint const& pointerPoint);
public void TryRedirectForManipulation(ExpPointerPoint pointerPoint);
function tryRedirectForManipulation(pointerPoint)
Public Sub TryRedirectForManipulation (pointerPoint As ExpPointerPoint)
パラメーター
- pointerPoint
- ExpPointerPoint
適用対象
TryRedirectForManipulation(PointerPoint)
特定のポインター ストリームに対して構成された操作を、指定された PointerPoint から開始して、アプリの UI スレッドではなく InteractionTracker に送信しようとします。
重要
このメソッドは、 Touch の PointerDeviceType でのみ呼び出す必要があります。
public:
virtual void TryRedirectForManipulation(PointerPoint ^ pointerPoint) = TryRedirectForManipulation;
void TryRedirectForManipulation(PointerPoint const& pointerPoint);
public void TryRedirectForManipulation(PointerPoint pointerPoint);
function tryRedirectForManipulation(pointerPoint)
Public Sub TryRedirectForManipulation (pointerPoint As PointerPoint)
パラメーター
- pointerPoint
- PointerPoint
入力ポイント。
例
次のコード スニペットは、入力/ジェスチャに従ってビジュアルを構成する方法を示しています。
これは、次の 3 つの主要な手順によって実現されます。
- InteractionTracker を作成し、境界を設定 (またはバインド) します。
- 少なくとも 1 つの VisualInteractionSource を作成し、それを InteractionTracker に関連付けます。
- InteractionTracker の出力を取得し、ビジュアルの Offset プロパティと Scale プロパティに適用 します。
- PointerPressed が発生したときに操作を処理するようにシステムに指示する
void SetupSimpleInteractionTracker(Visual containerVisual, Visual contentVisual)
{
//
// Create the InteractionTracker and set its min/max position and scale.
// These could also be bound to expressions.
//
// Note:
// The scrollable area can be changed from either end for content updates/virtualization.
//
_tracker = InteractionTracker.Create(_compositor);
_tracker.MaxPosition = new Vector3(
contentVisual.Size.X - containerVisual.Size.X,
contentVisual.Size.Y - containerVisual.Size.Y,
0.0f);
_tracker.MinScale = 0.5f;
_tracker.MaxScale = 4.0f;
//
// Configure the interaction source. Enable input with inertia on all axes.
//
_interactionSource = VisualInteractionSource.Create(_compositor, containerVisual);
_interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;
_interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia;
_interactionSource.ScaleSourceMode = InteractionSourceMode.EnabledWithInertia;
_tracker.InteractionSources.Add(_interactionSource);
//
// Register for the pointer pressed event so that we can tell the system to handle the
// manipulations.
//
_rootElement.PointerPressed += OnPointerPressedBasic;
//
// Bind the InteractionTracker outputs to the contentVisual.
//
var positionExpression = _compositor.CreateExpressionAnimation("-tracker.Position");
positionExpression.SetReferenceParameter("tracker", _tracker);
contentVisual.StartAnimation("Offset", positionExpression);
var scaleExpression = _compositor.CreateExpressionAnimation("Vector3(tracker.Scale, tracker.Scale, 1.0)");
scaleExpression.SetReferenceParameter("tracker", _tracker);
contentVisual.StartAnimation("Scale", scaleExpression);
}
private void OnPointerPressedBasic(object sender, PointerRoutedEventArgs e)
{
//
// Try to handle the manipulation in the system.
//
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch)
{
_interactionSource.TryRedirectForManipulation(
e.CurrentPoint.GetCurrentPoint(_rootElement));
}
}
Compositor _compositor = null;
InteractionTracker _tracker = null;
UIElement _rootElement = null;
VisualInteractionSource _interactionSource;
注釈
このメソッドを使用すると、アプリは、特定の VisualInteractionSource に対して構成された操作をシステム (コンポジター) が引き継ぐ必要があることを示します。 TryRedirectForManipulation が呼び出されると、渡された PointerPoint のフレームが InteractionTracker による入力処理の開始点として使用されます。 VisualInteractionSource (またはその子の 1 つ) に関連付けられているビジュアルに対してユーザーのジェスチャがヒット テストされ、ユーザーが構成されたジェスチャを実行すると、システムは操作します。 入力が別のビジュアルにヒット テストされている場合、またはユーザーが構成されていないジェスチャを実行した場合、入力は CoreWindow に送信され、標準の入力ルーティングを通じて送信されます。
VisualInteractionSource が入力ストリームを InteractionTracker に再ルーティングする場合、アプリケーションは UIElement の InputPointerSource.PointerCaptureLost または CoreWindow の InputPointerSource.PointerRoutedAway を受け取ります。 これらのメッセージは、入力がアプリケーション UI スレッドから送信されたことを示します。 このメソッドは、 PointerPressed で最も一般的に呼び出されます。
注意
PrecisionTouchpad 入力は、この呼び出しを必要とせず、InputRedirectionMode が CapableTouchpad 入力を含むように設定されている場合、適切なジェスチャのために InteractionTracker に自動的にルーティングされます。
非同期動作
このシステムの性質は非同期です。 アプリが TryRedirectForManipulation を呼び出し、呼び出しがコンポジターに到達するまでに、アプリケーションの UI スレッドに追加の入力イベントが発生する可能性があります。 ほとんどの場合、アプリがこれらのイベントを受信しても有害ではなく、アプリでジェスチャ検出を選択して、入力の処理方法を決定できます。 アプリは、 PointerCaptureLost (ScrollViewer が入力処理を引き継ぐときに受信したのと同じイベント) を受け取ることによって、システム操作が引き継ぐかどうかを認識します。 1 つの問題は、コンポジターが応答する前に、"クイック フリック" (短いスワイプ) のようなジェスチャで、PointerReleased を含む入力ストリーム全体をアプリケーションに送信できることです。 アプリがこれらの制限の影響を受ける場合は、適切な動作を確保するためにジェスチャ検出を行う必要がある場合があります。
XAML コントロール ロジックとの統合
上記のクイック フリック シナリオでは、パンがボタンのようなコントロール上にある場合、ボタンがボタン内に含まれている場合は、パンがクリックとして検出されます。 これは、ルーティングを実行しているシステム GestureRecognizer がジェスチャを検出する方法とは少し異なります。 XAML でクイック フリックの種類のシナリオが正しく動作するようにするには、コンポジターの相互作用領域内にある場合はクリックするだけではなく、ボタンで OnTapped をリッスンする必要があります。
コンポジターのヒット テスト
適切なビジュアルで操作が行われているかどうかを判断するために使用されるヒット テストの結果は、コンポジターのヒット テストに基づいています。 コンポジターのヒット テストは XAML ヒット テストほど堅牢ではありません。そのため、結果に若干の不一致が生じる場合があります。
競合するカスタム ジェスチャ認識エンジンとの統合
内部的には、システム GestureRecognizer が入力のルーティングに使用されています。 通常、アプリはシステム ジェスチャ認識を使用している限り、必要な動作を取得できます。 アプリがシステム認識エンジンと競合するカスタム認識エンジンを使用しようとしている場合は、コンポジターが引き継ぐとアプリが想定していて、引き継がれないという競合が発生する可能性があります。
適用対象
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示