diff options
author | iain holmes <iain@xamarin.com> | 2021-06-10 14:22:42 +0300 |
---|---|---|
committer | iain holmes <iain@xamarin.com> | 2021-06-10 14:22:42 +0300 |
commit | e0878f121d370e3e0d2b2e77ebfc00c7e72379f9 (patch) | |
tree | 4c7797574461c45f417db472b8cbe0dbbf77baaa | |
parent | 11ec2ea4b79e42c5571c17d85a0f8446698f9698 (diff) |
[Xwt] Store the characters data from NSEvent in KeyEventArgs
-rw-r--r-- | Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs | 2 | ||||
-rw-r--r-- | Xwt/Xwt/KeyEventArgs.cs | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs b/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs index 50f3b981..e79eb2e8 100644 --- a/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs +++ b/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs @@ -35,7 +35,7 @@ namespace Xwt.Mac { Key key = GetXwtKey(keyEvent); ModifierKeys mod = keyEvent.ModifierFlags.ToXwtValue (); - return new KeyEventArgs (key, keyEvent.KeyCode, mod, keyEvent.IsARepeat, (long)TimeSpan.FromSeconds (keyEvent.Timestamp).TotalMilliseconds); + return new KeyEventArgs (key, keyEvent.KeyCode, mod, keyEvent.IsARepeat, (long)TimeSpan.FromSeconds (keyEvent.Timestamp).TotalMilliseconds, keyEvent.Characters, keyEvent.CharactersIgnoringModifiers); } static Key GetXwtKey (NSEvent keyEvent) diff --git a/Xwt/Xwt/KeyEventArgs.cs b/Xwt/Xwt/KeyEventArgs.cs index dd02b5b8..3fae13de 100644 --- a/Xwt/Xwt/KeyEventArgs.cs +++ b/Xwt/Xwt/KeyEventArgs.cs @@ -39,12 +39,14 @@ namespace Xwt /// <param name="modifiers">The modifier keys.</param> /// <param name="isRepeat">the key has been pressed more then once.</param> /// <param name="timestamp">The timestamp of the key event.</param> - public KeyEventArgs (Key key, ModifierKeys modifiers, bool isRepeat, long timestamp) + public KeyEventArgs (Key key, ModifierKeys modifiers, bool isRepeat, long timestamp, string characters = "", string charactersIgnoringModifiers = "") { this.Key = key; this.Modifiers = modifiers; this.IsRepeat = isRepeat; this.Timestamp = timestamp; + this.Characters = characters; + this.CharactersIgnoringModifiers = charactersIgnoringModifiers; } /// <summary> @@ -55,8 +57,8 @@ namespace Xwt /// <param name="modifiers">The modifier keys.</param> /// <param name="isRepeat">the key has been pressed more then once.</param> /// <param name="timestamp">The timestamp of the key event.</param> - public KeyEventArgs (Key key, int nativeKeyCode, ModifierKeys modifiers, bool isRepeat, long timestamp) - : this (key, modifiers, isRepeat, timestamp) + public KeyEventArgs (Key key, int nativeKeyCode, ModifierKeys modifiers, bool isRepeat, long timestamp, string characters = "", string charactersIgnoringModifiers = "") + : this (key, modifiers, isRepeat, timestamp, characters, charactersIgnoringModifiers) { this.NativeKeyCode = nativeKeyCode; } @@ -103,6 +105,9 @@ namespace Xwt /// the backend from processing the key and adding the appropriate character to <see cref="Xwt.TextEntry.Text"/>. /// </remarks> public bool Handled { get; set; } + + public string Characters { get; private set; } + public string CharactersIgnoringModifiers { get; private set; } } } |