зеркало из https://github.com/AvaloniaUI/Avalonia.git
Родитель
a9a569557b
Коммит
3a09abe30b
|
@ -11,9 +11,9 @@ namespace Perspex.Input
|
|||
|
||||
public interface IPointerDevice : IInputDevice
|
||||
{
|
||||
IInteractive Captured { get; }
|
||||
IInputElement Captured { get; }
|
||||
|
||||
void Capture(IInteractive control);
|
||||
void Capture(IInputElement control);
|
||||
|
||||
Point GetPosition(IVisual relativeTo);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Perspex.Input
|
|||
.Subscribe(this.ProcessRawEvent);
|
||||
}
|
||||
|
||||
public IInteractive Captured
|
||||
public IInputElement Captured
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
|
@ -47,7 +47,7 @@ namespace Perspex.Input
|
|||
protected set;
|
||||
}
|
||||
|
||||
public virtual void Capture(IInteractive control)
|
||||
public virtual void Capture(IInputElement control)
|
||||
{
|
||||
this.Captured = control;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace Perspex.Input
|
|||
|
||||
private void MouseDown(IMouseDevice device, uint timestamp, IInputElement root, Point p)
|
||||
{
|
||||
IVisual hit = root.InputHitTest(p);
|
||||
var hit = this.HitTest(root, p);
|
||||
|
||||
if (hit != null)
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ namespace Perspex.Input
|
|||
|
||||
private void MouseUp(IMouseDevice device, IInputElement root, Point p)
|
||||
{
|
||||
IVisual hit = root.InputHitTest(p);
|
||||
var hit = this.HitTest(root, p);
|
||||
|
||||
if (hit != null)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ namespace Perspex.Input
|
|||
|
||||
private void MouseWheel(IMouseDevice device, IInputElement root, Point p, Vector delta)
|
||||
{
|
||||
IVisual hit = root.InputHitTest(p);
|
||||
var hit = this.HitTest(root, p);
|
||||
|
||||
if (hit != null)
|
||||
{
|
||||
|
@ -222,5 +222,10 @@ namespace Perspex.Input
|
|||
(hit as IInteractive) ??
|
||||
hit.GetSelfAndVisualAncestors().OfType<IInteractive>().FirstOrDefault();
|
||||
}
|
||||
|
||||
private IInputElement HitTest(IInputElement root, Point p)
|
||||
{
|
||||
return this.Captured ?? root.InputHitTest(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Perspex.Win32.Input
|
|||
{
|
||||
using System;
|
||||
using Perspex.Input;
|
||||
using Perspex.Interactivity;
|
||||
using Perspex.Win32.Interop;
|
||||
|
||||
public class WindowsMouseDevice : MouseDevice
|
||||
|
@ -31,6 +32,20 @@ namespace Perspex.Win32.Input
|
|||
internal set { base.Position = value; }
|
||||
}
|
||||
|
||||
public override void Capture(IInputElement control)
|
||||
{
|
||||
base.Capture(control);
|
||||
|
||||
if (control != null)
|
||||
{
|
||||
UnmanagedMethods.SetCapture(this.CurrentWindow.Handle.Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnmanagedMethods.ReleaseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Point GetClientPosition()
|
||||
{
|
||||
UnmanagedMethods.POINT p;
|
||||
|
|
Загрузка…
Ссылка в новой задаче