public void On_Capture_Transfer_PointerCaptureLost_Should_Propagate_Up_To_The_Common_Parent() { Border initialParent, initialCapture, newParent, newCapture; var el = new StackPanel { Children = { (initialParent = new Border { Child = initialCapture = new Border() }), (newParent = new Border { Child = newCapture = new Border() }) } }; var receivers = new List <object>(); var root = new TestRoot(el); foreach (InputElement d in root.GetSelfAndVisualDescendants()) { d.PointerCaptureLost += (s, e) => receivers.Add(s); } var pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); pointer.Capture(initialCapture); pointer.Capture(newCapture); Assert.True(receivers.SequenceEqual(new[] { initialCapture, initialParent })); receivers.Clear(); pointer.Capture(null); Assert.True(receivers.SequenceEqual(new object[] { newCapture, newParent, el, root })); }
public void Down(IInteractive target, IInteractive source, MouseButton mouseButton = MouseButton.Left, Point position = default, InputModifiers modifiers = default, int clickCount = 1) { _pressedButtons |= Convert(mouseButton); var props = new PointerPointProperties(_pressedButtons); if (ButtonCount(props) > 1) { Move(target, source, position); } else { _pressedButton = mouseButton; _pointer.Capture((IInputElement)target); target.RaiseEvent(new PointerPressedEventArgs(source, _pointer, (IVisual)source, position, Timestamp(), props, GetModifiers(modifiers), clickCount)); } }
public void Down(IInteractive target, IInteractive source, MouseButton mouseButton = MouseButton.Left, Point position = default, InputModifiers modifiers = default, int clickCount = 1) { _pressedButtons |= Convert(mouseButton); var props = new PointerPointProperties((RawInputModifiers)_pressedButtons, mouseButton == MouseButton.Left ? PointerUpdateKind.LeftButtonPressed : mouseButton == MouseButton.Middle ? PointerUpdateKind.MiddleButtonPressed : mouseButton == MouseButton.Right ? PointerUpdateKind.RightButtonPressed : PointerUpdateKind.Other ); if (ButtonCount(props) > 1) { Move(target, source, position); } else { _pressedButton = mouseButton; _pointer.Capture((IInputElement)target); source.RaiseEvent(new PointerPressedEventArgs(source, _pointer, (IVisual)source, position, Timestamp(), props, GetModifiers(modifiers), clickCount)); } }