|
|
|
@ -7,14 +7,18 @@ |
|
|
|
namespace Perspex.Input |
|
|
|
{ |
|
|
|
using System; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using Perspex.Input.Raw; |
|
|
|
using Perspex.Interactivity; |
|
|
|
using Splat; |
|
|
|
|
|
|
|
public abstract class KeyboardDevice : IKeyboardDevice |
|
|
|
public abstract class KeyboardDevice : IKeyboardDevice, INotifyPropertyChanged |
|
|
|
{ |
|
|
|
private IInputElement focusedElement; |
|
|
|
|
|
|
|
public KeyboardDevice() |
|
|
|
{ |
|
|
|
this.InputManager.RawEventReceived |
|
|
|
@ -23,6 +27,8 @@ namespace Perspex.Input |
|
|
|
.Subscribe(this.ProcessRawEvent); |
|
|
|
} |
|
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged; |
|
|
|
|
|
|
|
public static IKeyboardDevice Instance |
|
|
|
{ |
|
|
|
get { return Locator.Current.GetService<IKeyboardDevice>(); } |
|
|
|
@ -40,8 +46,16 @@ namespace Perspex.Input |
|
|
|
|
|
|
|
public IInputElement FocusedElement |
|
|
|
{ |
|
|
|
get; |
|
|
|
private set; |
|
|
|
get |
|
|
|
{ |
|
|
|
return this.focusedElement; |
|
|
|
} |
|
|
|
|
|
|
|
private set |
|
|
|
{ |
|
|
|
this.focusedElement = value; |
|
|
|
this.RaisePropertyChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public abstract ModifierKeys Modifiers { get; } |
|
|
|
@ -74,6 +88,11 @@ namespace Perspex.Input |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected void RaisePropertyChanged([CallerMemberName] string propertyName = "") |
|
|
|
{ |
|
|
|
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
|
|
|
} |
|
|
|
|
|
|
|
private void ProcessRawEvent(RawKeyEventArgs e) |
|
|
|
{ |
|
|
|
IInputElement element = this.FocusedElement; |
|
|
|
|