Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriain <iaholmes@microsoft.com>2021-06-25 16:11:56 +0300
committerGitHub <noreply@github.com>2021-06-25 16:11:56 +0300
commitf5d66126193016e09bc9e983693a4e097e9d2855 (patch)
tree7e0020c583388ad12b334ad5cda6659bafd1a254
parent219681418d9595666e7cb41caad103a056750e26 (diff)
parent1cdcf0f2ce12cc4394cb6d314153c34f73d1f74d (diff)
Merge pull request #1059 from mono/dev/iain/fix-event-api
[Xwt] Fix the KeyEventArgs api to add overloads for characters
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend.CellViews/CellViewBackend.cs4
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs4
-rw-r--r--Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs2
-rw-r--r--Xwt/Xwt/KeyEventArgs.cs67
4 files changed, 68 insertions, 9 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend.CellViews/CellViewBackend.cs b/Xwt.Gtk/Xwt.GtkBackend.CellViews/CellViewBackend.cs
index f99de93a..124a7128 100644
--- a/Xwt.Gtk/Xwt.GtkBackend.CellViews/CellViewBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend.CellViews/CellViewBackend.cs
@@ -294,7 +294,7 @@ namespace Xwt.GtkBackend
Key k = (Key)args.Event.KeyValue;
ModifierKeys m = args.Event.State.ToXwtValue ();
- KeyEventArgs kargs = new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time);
+ KeyEventArgs kargs = new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time, string.Empty, string.Empty, args.Event);
ApplicationContext.InvokeUserCode (delegate {
EventSink.OnKeyPressed (kargs);
});
@@ -308,7 +308,7 @@ namespace Xwt.GtkBackend
Key k = (Key)args.Event.KeyValue;
ModifierKeys m = args.Event.State.ToXwtValue ();
- KeyEventArgs kargs = new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time);
+ KeyEventArgs kargs = new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time, string.Empty, string.Empty, args.Event);
ApplicationContext.InvokeUserCode (delegate {
EventSink.OnKeyReleased (kargs);
});
diff --git a/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs
index 10cf3289..67728f84 100644
--- a/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/WidgetBackend.cs
@@ -704,7 +704,7 @@ namespace Xwt.GtkBackend
if ((args.Event.State & Gdk.ModifierType.Mod1Mask) != 0)
m |= ModifierKeys.Alt;
- return new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time);
+ return new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time, string.Empty, string.Empty, args.Event);
}
[GLib.ConnectBefore]
@@ -725,7 +725,7 @@ namespace Xwt.GtkBackend
Key k = (Key)args.Event.KeyValue;
ModifierKeys m = args.Event.State.ToXwtValue ();
- return new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time);
+ return new KeyEventArgs (k, (int)args.Event.KeyValue, m, false, (long)args.Event.Time, string.Empty, string.Empty, args.Event);
}
protected Gtk.IMContext IMContext { get; set; }
diff --git a/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs b/Xwt.XamMac/Xwt.Mac/KeyboardUtil.cs
index e79eb2e8..47aecd32 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, keyEvent.Characters, keyEvent.CharactersIgnoringModifiers);
+ return new KeyEventArgs (key, keyEvent.KeyCode, mod, keyEvent.IsARepeat, (long)TimeSpan.FromSeconds (keyEvent.Timestamp).TotalMilliseconds, keyEvent.Characters, keyEvent.CharactersIgnoringModifiers, keyEvent);
}
static Key GetXwtKey (NSEvent keyEvent)
diff --git a/Xwt/Xwt/KeyEventArgs.cs b/Xwt/Xwt/KeyEventArgs.cs
index 3fae13de..452f6b89 100644
--- a/Xwt/Xwt/KeyEventArgs.cs
+++ b/Xwt/Xwt/KeyEventArgs.cs
@@ -39,7 +39,9 @@ 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, string characters = "", string charactersIgnoringModifiers = "")
+ /// <param name="characters">The character string this event represents</param>
+ /// <param name="charactersIgnoringModifiers">The character string this event represents ignoring any modifier keys that are pressed</param>
+ public KeyEventArgs (Key key, ModifierKeys modifiers, bool isRepeat, long timestamp, string characters, string charactersIgnoringModifiers)
{
this.Key = key;
this.Modifiers = modifiers;
@@ -48,7 +50,18 @@ namespace Xwt
this.Characters = characters;
this.CharactersIgnoringModifiers = charactersIgnoringModifiers;
}
-
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Xwt.KeyEventArgs"/> class.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <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) : this (key, modifiers, isRepeat, timestamp, string.Empty, string.Empty)
+ {
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="Xwt.KeyEventArgs"/> class.
/// </summary>
@@ -57,12 +70,43 @@ 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, string characters = "", string charactersIgnoringModifiers = "")
+ /// <param name="characters">The character string this event represents</param>
+ /// <param name="charactersIgnoringModifiers">The character string this event represents ignoring any modifier keys that are pressed</param>
+ 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;
}
-
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Xwt.KeyEventArgs"/> class.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="nativeKeyCode">The native key code.</param>
+ /// <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, nativeKeyCode, modifiers, isRepeat, timestamp, string.Empty, string.Empty)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Xwt.KeyEventArgs"/> class.
+ /// </summary>
+ /// <param name="key">The key.</param>
+ /// <param name="nativeKeyCode">The native key code.</param>
+ /// <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>
+ /// <param name="characters">The character string this event represents</param>
+ /// <param name="charactersIgnoringModifiers">The character string this event represents ignoring any modifier keys that are pressed</param>
+ /// <param name="nativeEvent">The native event object</param>
+ public KeyEventArgs(Key key, int nativeKeyCode, ModifierKeys modifiers, bool isRepeat, long timestamp, string characters, string charactersIgnoringModifiers, object nativeEvent)
+ : this(key, nativeKeyCode, modifiers, isRepeat, timestamp, characters, charactersIgnoringModifiers)
+ {
+ this.NativeEvent = nativeEvent;
+ }
+
/// <summary>
/// Gets the key.
/// </summary>
@@ -106,8 +150,23 @@ namespace Xwt
/// </remarks>
public bool Handled { get; set; }
+ /// <summary>
+ /// Gets or sets the character representation of the event
+ /// </summary>
+ /// <value>The string of characters</value>
public string Characters { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the character representation of the event ignoring the modifier keys
+ /// </summary>
+ /// <value>The string of characters</value>
public string CharactersIgnoringModifiers { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the native event object
+ /// </summary>
+ /// <value>An opaque object representing the event in the native toolkit</value>
+ public object NativeEvent { get; private set; }
}
}