diff --git a/src/Perspex.Controls/TopLevel.cs b/src/Perspex.Controls/TopLevel.cs index fe87d3ce9f..f5c22e8c41 100644 --- a/src/Perspex.Controls/TopLevel.cs +++ b/src/Perspex.Controls/TopLevel.cs @@ -392,7 +392,7 @@ namespace Perspex.Controls /// The event args. private void HandleInput(RawInputEventArgs e) { - _inputManager.Process(e); + _inputManager.ProcessInput(e); } /// diff --git a/src/Perspex.Diagnostics/DevTools.xaml.cs b/src/Perspex.Diagnostics/DevTools.xaml.cs index 3b5b6ada44..a6e4e83533 100644 --- a/src/Perspex.Diagnostics/DevTools.xaml.cs +++ b/src/Perspex.Diagnostics/DevTools.xaml.cs @@ -26,7 +26,7 @@ namespace Perspex.Diagnostics Root = root; DataContext = new DevToolsViewModel(root); - _keySubscription = InputManager.Instance.RawEventReceived + _keySubscription = InputManager.Instance.Process .OfType() .Subscribe(RawKeyDown); } diff --git a/src/Perspex.Input/IInputManager.cs b/src/Perspex.Input/IInputManager.cs index 4f61f8f756..ca600d8461 100644 --- a/src/Perspex.Input/IInputManager.cs +++ b/src/Perspex.Input/IInputManager.cs @@ -3,16 +3,36 @@ using System; using Perspex.Input.Raw; -using Perspex.Layout; namespace Perspex.Input { + /// + /// Recieves input from the windowing subsystem and dispatches it to interested parties + /// for processing. + /// public interface IInputManager { - IObservable RawEventReceived { get; } + /// + /// Gets an observable that notifies on each input event recieved before + /// . + /// + IObservable PreProcess { get; } + /// + /// Gets an observable that notifies on each input event recieved. + /// + IObservable Process { get; } + + /// + /// Gets an observable that notifies on each input event recieved after + /// . + /// IObservable PostProcess { get; } - void Process(RawInputEventArgs e); + /// + /// Processes a raw input event. + /// + /// The raw input event. + void ProcessInput(RawInputEventArgs e); } } diff --git a/src/Perspex.Input/InputManager.cs b/src/Perspex.Input/InputManager.cs index eb25850d3d..e12b7d2b27 100644 --- a/src/Perspex.Input/InputManager.cs +++ b/src/Perspex.Input/InputManager.cs @@ -2,28 +2,39 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Linq; using System.Reactive.Subjects; using Perspex.Input.Raw; namespace Perspex.Input { + /// + /// Recieves input from the windowing subsystem and dispatches it to interested parties + /// for processing. + /// public class InputManager : IInputManager { - private readonly Subject _rawEventReceived = new Subject(); - + private readonly Subject _preProcess = new Subject(); + private readonly Subject _process = new Subject(); private readonly Subject _postProcess = new Subject(); + /// + /// Gets the global instance of the input manager. + /// public static IInputManager Instance => PerspexLocator.Current.GetService(); - public IObservable RawEventReceived => _rawEventReceived; + /// + public IObservable PreProcess => _preProcess; + + /// + public IObservable Process => _process; + /// public IObservable PostProcess => _postProcess; - public void Process(RawInputEventArgs e) + /// + public void ProcessInput(RawInputEventArgs e) { - _rawEventReceived.OnNext(e); + _process.OnNext(e); _postProcess.OnNext(e); } } diff --git a/src/Perspex.Input/KeyboardDevice.cs b/src/Perspex.Input/KeyboardDevice.cs index be9e8833dc..6967b23fba 100644 --- a/src/Perspex.Input/KeyboardDevice.cs +++ b/src/Perspex.Input/KeyboardDevice.cs @@ -18,9 +18,9 @@ namespace Perspex.Input public KeyboardDevice() { - InputManager.RawEventReceived + InputManager.Process .OfType() - .Where(x => x.Device == this) + .Where(e => e.Device == this && !e.Handled) .Subscribe(ProcessRawEvent); } diff --git a/src/Perspex.Input/MouseDevice.cs b/src/Perspex.Input/MouseDevice.cs index 303096ecef..fb204e9912 100644 --- a/src/Perspex.Input/MouseDevice.cs +++ b/src/Perspex.Input/MouseDevice.cs @@ -27,9 +27,9 @@ namespace Perspex.Input /// public MouseDevice() { - InputManager.RawEventReceived + InputManager.Process .OfType() - .Where(x => x.Device == this) + .Where(e => e.Device == this && !e.Handled) .Subscribe(ProcessRawEvent); } diff --git a/tests/Perspex.Controls.UnitTests/TopLevelTests.cs b/tests/Perspex.Controls.UnitTests/TopLevelTests.cs index d121ad06ff..edb1ac1977 100644 --- a/tests/Perspex.Controls.UnitTests/TopLevelTests.cs +++ b/tests/Perspex.Controls.UnitTests/TopLevelTests.cs @@ -251,7 +251,7 @@ namespace Perspex.Controls.UnitTests Key.A, InputModifiers.None); impl.Object.Input(input); - inputManagerMock.Verify(x => x.Process(input)); + inputManagerMock.Verify(x => x.ProcessInput(input)); } }