다음을 통해 공유


VisualInteractionSource.TryRedirectForManipulation(PointerPoint) 메서드

정의

지정된 포인터 스트림에 대해 구성된 조작이 지정된 PointerPoint에서 시작하여 앱의 UI 스레드가 아닌 InteractionTracker로 전송되어야 했음을 나타냅니다.

TryRedirectForManipulation을 사용하면 제스처가 VisualInteractionSource의 구성과 일치하는 경우 VisualInteractionSource에서 Pointer 스트림을 InteractionTracker로 리디렉션할 수 있습니다. 이 메서드는 DeviceType Touch의 포인터 입력으로만 호출해야 합니다.

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

지정된 포인터 스트림에 대해 구성된 조작이 지정된 PointerPoint에서 시작하여 앱의 UI 스레드가 아닌 InteractionTracker로 전송되어야 했음을 나타냅니다.

예제

///////////////////////////////////////////////////////////////////////////////////////////////
//
// The following sample describes how to configure a visual to follow input/gestures.  
//
// This is accomplished in three main steps:
//
// 1) Creating a InteractionTracker and setting (or binding) its boundaries.
//
// 2) Creating at least one Interaction source and associating it with the InteractionTracker.
//
// 3) Taking the output of the InteractionTracker and applying it to a Visual's Offset and Scale 
//    properties.
//
// 4) Telling the system to try to handle the manipulation when the PointerPressed occurs
//
///////////////////////////////////////////////////////////////////////////////////////////////

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 to facilitate 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;

설명

이 메서드를 사용하면 앱에서 시스템(Compositor)이 지정된 VisualInteractionSource에 대해 구성된 모든 조작을 인수해야 함을 나타낼 수 있습니다. TryRedirectForManipulation이 호출되면 PointerPoint에 전달된 의 프레임이 InteractionTracker 의 입력 처리의 시작점으로 사용됩니다. 사용자의 제스처가 VisualInteractionSource (또는 해당 자식 중 하나)와 연결된 시각적 개체에 적중 테스트되고 사용자가 구성된 제스처를 수행하는 경우 시스템이 조작합니다. 입력이 다른 시각적 개체에 적중 테스트를 수행하거나 사용자가 구성되지 않은 제스처를 수행하는 경우 입력은 CoreWindow 및 XAML의 일반 입력 라우팅을 통해 전송됩니다.

VisualInteractionSource가 입력 스트림을 InteractionTracker로 다시 라우팅하는 경우 애플리케이션은 UIElement에서 PointerCaptureLost 또는 CoreWindow의 PointerRoutedAway를 받게 됩니다. 이러한 메시지는 입력이 애플리케이션 UI 스레드에서 멀리 전송되었음을 나타냅니다. 이 메서드는 PointerPressed에서 가장 일반적으로 호출됩니다.

PrecisionTouchpad 입력에는 이 호출이 필요하지 않으며 InputRedirectionMode가 CapableTouchpad 입력을 포함하도록 설정된 경우 적절한 제스처에 대해 InteractionTracker 로 자동으로 라우팅됩니다.

제한 사항

비동기 자연

이 시스템의 특성은 비동기적입니다. 앱이 TryRedirectForManipulation을 호출하고 호출이 작성자에 도달할 때까지 애플리케이션의 UI 스레드에 만들 수 있는 추가 입력 이벤트가 있습니다. 대부분의 경우 앱이 이러한 이벤트를 수신하는 것은 해롭지 않으며 개발자는 앱 쪽을 제스처하여 입력을 처리하고 문제를 완화하는 방법을 결정할 수 있습니다. 앱은 ScrollViewer가 오늘 입력 처리를 인수할 때 받은 것과 동일한 이벤트인 PointerCaptureLost를 수신하여 시스템 조작이 인계되는지 여부를 알 수 있습니다. 여기서 한 가지 합병증은 "빠른 터치"(짧은 팬)와 같은 제스처가 PointerReleased를 포함한 전체 입력 스트림을 작성자가 응답하기 전에 애플리케이션에 보낼 수 있다는 것입니다. 앱이 이러한 제한 사항의 영향을 받는 경우 적절한 동작을 보장하기 위해 해당 쪽에서 일정량의 제스처 검색을 수행하도록 선택할 수 있습니다.

XAML 컨트롤 논리와 통합

위에서 설명한 빠른 터치 시나리오에서 이동이 단추와 같은 컨트롤에 있는 경우 단추는 단추 내에 포함된 경우 클릭으로 팬을 검색합니다. 이는 시스템 GestureRecognizer(라우팅을 수행하는)가 제스처를 검색하는 방식과 약간 다릅니다. 빠른 터치 유형 시나리오가 XAML에서 제대로 작동하도록 하려면 개발자가 작성기 상호 작용 영역 내에 있는 경우 클릭이 아니라 단추에서 OnTapped을 수신 대기해야 합니다.

작성기 적중 테스트

올바른 시각적 개체에서 조작이 발생하는지 확인하는 데 사용되는 적중 테스트 결과는 작성자의 적중 테스트를 기반으로 합니다. Compositor 적중 테스트는 XAML 적중 테스트만큼 강력하지 않으므로 결과가 약간 불일치할 수 있는 경우가 있습니다.

자세한 내용은 VisualInteractionSource설명서를 참조하세요.

충돌하는 사용자 지정 제스처 인식기와 통합

내부적으로 시스템 GestureRecognizer는 입력을 라우팅하는 데 사용됩니다. 앱은 일반적으로 시스템 제스처 인식을 사용하는 한 원하는 동작을 가져올 수 있습니다. 앱이 시스템 인식기와 충돌하는 사용자 지정 인식기를 사용하려고 하면 앱이 작성자를 인수할 것으로 예상하고 그렇지 않은 충돌이 있을 수 있습니다.

적용 대상