|
|
|
@ -7,6 +7,7 @@ |
|
|
|
namespace Perspex.Input |
|
|
|
{ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using Perspex.Input.Raw; |
|
|
|
@ -23,6 +24,8 @@ namespace Perspex.Input |
|
|
|
|
|
|
|
private uint lastClickTime; |
|
|
|
|
|
|
|
private List<IInputElement> pointerOvers = new List<IInputElement>(); |
|
|
|
|
|
|
|
public MouseDevice() |
|
|
|
{ |
|
|
|
this.InputManager.RawEventReceived |
|
|
|
@ -102,7 +105,7 @@ namespace Perspex.Input |
|
|
|
|
|
|
|
private void LeaveWindow(IMouseDevice device, IInputElement root) |
|
|
|
{ |
|
|
|
this.InputManager.ClearPointerOver(this); |
|
|
|
this.ClearPointerOver(this); |
|
|
|
} |
|
|
|
|
|
|
|
private void MouseDown(IMouseDevice device, uint timestamp, IInputElement root, Point p) |
|
|
|
@ -155,7 +158,7 @@ namespace Perspex.Input |
|
|
|
|
|
|
|
if (this.Captured == null) |
|
|
|
{ |
|
|
|
this.InputManager.SetPointerOver(this, root, p); |
|
|
|
this.SetPointerOver(this, root, p); |
|
|
|
source = root as IInteractive; |
|
|
|
} |
|
|
|
else |
|
|
|
@ -167,7 +170,7 @@ namespace Perspex.Input |
|
|
|
offset += ancestor.Bounds.Position; |
|
|
|
} |
|
|
|
|
|
|
|
this.InputManager.SetPointerOver(this, this.Captured, p - offset); |
|
|
|
this.SetPointerOver(this, this.Captured, p - offset); |
|
|
|
source = this.Captured as IInteractive; |
|
|
|
} |
|
|
|
|
|
|
|
@ -253,5 +256,55 @@ namespace Perspex.Input |
|
|
|
{ |
|
|
|
return this.Captured ?? root.InputHitTest(p); |
|
|
|
} |
|
|
|
|
|
|
|
private void ClearPointerOver(IPointerDevice device) |
|
|
|
{ |
|
|
|
foreach (var control in this.pointerOvers.ToList()) |
|
|
|
{ |
|
|
|
PointerEventArgs e = new PointerEventArgs |
|
|
|
{ |
|
|
|
RoutedEvent = InputElement.PointerLeaveEvent, |
|
|
|
Device = device, |
|
|
|
OriginalSource = control, |
|
|
|
Source = control, |
|
|
|
}; |
|
|
|
|
|
|
|
this.pointerOvers.Remove(control); |
|
|
|
control.RaiseEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void SetPointerOver(IPointerDevice device, IInputElement element, Point p) |
|
|
|
{ |
|
|
|
IEnumerable<IInputElement> hits = element.GetInputElementsAt(p); |
|
|
|
|
|
|
|
foreach (var control in this.pointerOvers.Except(hits).ToList()) |
|
|
|
{ |
|
|
|
PointerEventArgs e = new PointerEventArgs |
|
|
|
{ |
|
|
|
RoutedEvent = InputElement.PointerLeaveEvent, |
|
|
|
Device = device, |
|
|
|
OriginalSource = control, |
|
|
|
Source = control, |
|
|
|
}; |
|
|
|
|
|
|
|
this.pointerOvers.Remove(control); |
|
|
|
control.RaiseEvent(e); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var control in hits.Except(this.pointerOvers)) |
|
|
|
{ |
|
|
|
PointerEventArgs e = new PointerEventArgs |
|
|
|
{ |
|
|
|
RoutedEvent = InputElement.PointerEnterEvent, |
|
|
|
Device = device, |
|
|
|
OriginalSource = control, |
|
|
|
Source = control, |
|
|
|
}; |
|
|
|
|
|
|
|
this.pointerOvers.Add(control); |
|
|
|
control.RaiseEvent(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|