Browse Source

Pass the device in PointerEventArgs.

pull/4/head
Steven Kirk 12 years ago
parent
commit
8450fe5e8b
  1. 15
      Perspex.Windows/Input/MouseDevice.cs
  2. 2
      Perspex/Controls/Control.cs
  3. 8
      Perspex/Input/IInputDevice.cs
  4. 14
      Perspex/Input/IMouseDevice.cs
  5. 17
      Perspex/Input/IPointerDevice.cs
  6. 10
      Perspex/Input/InputManager.cs
  7. 1
      Perspex/Input/PointerEventArgs.cs
  8. 2
      Perspex/Perspex.csproj

15
Perspex.Windows/Input/MouseDevice.cs

@ -6,9 +6,22 @@
namespace Perspex.Windows.Input
{
using System;
using System.Reactive.Disposables;
using Perspex.Input;
public class MouseDevice : IInputDevice
public class MouseDevice : IMouseDevice
{
public IVisual Captured
{
get;
private set;
}
public IDisposable Capture(IVisual visual)
{
this.Captured = visual;
return Disposable.Create(() => this.Captured = null);
}
}
}

2
Perspex/Controls/Control.cs

@ -220,7 +220,7 @@ namespace Perspex.Controls
public bool IsPointerOver
{
get { return this.GetValue(IsPointerOverProperty); }
set { this.SetValue(IsPointerOverProperty, value); }
internal set { this.SetValue(IsPointerOverProperty, value); }
}
public HorizontalAlignment HorizontalAlignment

8
Perspex/Input/IInputDevice.cs

@ -1,17 +1,11 @@
// -----------------------------------------------------------------------
// <copyright file="IInputDevice.cs" company="Steven Kirk">
// Copyright 2013 MIT Licence. See licence.md for more information.
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Input
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public interface IInputDevice
{
}

14
Perspex/Input/IMouseDevice.cs

@ -0,0 +1,14 @@
// -----------------------------------------------------------------------
// <copyright file="IMouseDevice.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Input
{
using System;
public interface IMouseDevice : IPointerDevice
{
}
}

17
Perspex/Input/IPointerDevice.cs

@ -0,0 +1,17 @@
// -----------------------------------------------------------------------
// <copyright file="IPointerDevice.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Input
{
using System;
public interface IPointerDevice : IInputDevice
{
IVisual Captured { get; }
IDisposable Capture(IVisual visual);
}
}

10
Perspex/Input/InputManager.cs

@ -29,10 +29,10 @@ namespace Perspex.Input
this.MouseMove((IVisual)e.Root, e.Position);
break;
case RawMouseEventType.LeftButtonDown:
this.MouseDown((IVisual)e.Root, e.Position);
this.MouseDown((IMouseDevice)e.Device, (IVisual)e.Root, e.Position);
break;
case RawMouseEventType.LeftButtonUp:
this.MouseUp((IVisual)e.Root, e.Position);
this.MouseUp((IMouseDevice)e.Device, (IVisual)e.Root, e.Position);
break;
}
}
@ -52,7 +52,7 @@ namespace Perspex.Input
}
}
private void MouseDown(IVisual visual, Point p)
private void MouseDown(IMouseDevice device, IVisual visual, Point p)
{
IVisual hit = visual.GetVisualAt(p);
@ -64,6 +64,7 @@ namespace Perspex.Input
{
source.RaiseEvent(new PointerEventArgs
{
Device = device,
RoutedEvent = Control.PointerPressedEvent,
OriginalSource = source,
Source = source,
@ -72,7 +73,7 @@ namespace Perspex.Input
}
}
private void MouseUp(IVisual visual, Point p)
private void MouseUp(IMouseDevice device, IVisual visual, Point p)
{
IVisual hit = visual.GetVisualAt(p);
@ -84,6 +85,7 @@ namespace Perspex.Input
{
source.RaiseEvent(new PointerEventArgs
{
Device = device,
RoutedEvent = Control.PointerReleasedEvent,
OriginalSource = source,
Source = source,

1
Perspex/Input/PointerEventArgs.cs

@ -10,5 +10,6 @@ namespace Perspex.Input
public class PointerEventArgs : RoutedEventArgs
{
public IPointerDevice Device { get; set; }
}
}

2
Perspex/Perspex.csproj

@ -73,6 +73,8 @@
<Compile Include="Controls\LogicalChildren.cs" />
<Compile Include="Controls\Panel.cs" />
<Compile Include="Controls\StackPanel.cs" />
<Compile Include="Input\IMouseDevice.cs" />
<Compile Include="Input\IPointerDevice.cs" />
<Compile Include="Input\IInputDevice.cs" />
<Compile Include="Input\IInputManager.cs" />
<Compile Include="Input\InputManager.cs" />

Loading…
Cancel
Save