Skip to content

Commit

Permalink
Obsolete old RawKeyEventArgs ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJul committed Aug 17, 2023
1 parent c6980e2 commit 97410ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Avalonia.Base/Input/Raw/RawKeyEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Avalonia.Metadata;

namespace Avalonia.Input.Raw
Expand All @@ -11,6 +12,7 @@ public enum RawKeyEventType
[PrivateApi]
public class RawKeyEventArgs : RawInputEventArgs
{
[Obsolete("Use the overload that takes a physical key and key symbol instead.")]
public RawKeyEventArgs(
IKeyboardDevice device,
ulong timestamp,
Expand Down
13 changes: 7 additions & 6 deletions src/iOS/Avalonia.iOS/TextInputResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ private void SurroundingTextChanged(object? sender, EventArgs e)
}
}

private void KeyPress(Key ev)
private void KeyPress(Key key, PhysicalKey physicalKey, string? keySymbol)
{
Logger.TryGet(LogEventLevel.Debug, ImeLog)?.Log(null, "Triggering key press {key}", ev);
Logger.TryGet(LogEventLevel.Debug, ImeLog)?.Log(null, "Triggering key press {key}", key);

_view._topLevelImpl.Input(new RawKeyEventArgs(KeyboardDevice.Instance!, 0, _view.InputRoot,
RawKeyEventType.KeyDown, ev, RawInputModifiers.None));
RawKeyEventType.KeyDown, key, RawInputModifiers.None, physicalKey, keySymbol));

_view._topLevelImpl.Input(new RawKeyEventArgs(KeyboardDevice.Instance!, 0, _view.InputRoot,
RawKeyEventType.KeyUp, ev, RawInputModifiers.None));
RawKeyEventType.KeyUp, key, RawInputModifiers.None, physicalKey, keySymbol));
}

private void TextInput(string text)
Expand All @@ -177,7 +178,7 @@ void IUIKeyInput.InsertText(string text)

if (text == "\n")
{
KeyPress(Key.Enter);
KeyPress(Key.Enter, PhysicalKey.Enter, "\r");

switch (ReturnKeyType)
{
Expand All @@ -194,7 +195,7 @@ void IUIKeyInput.InsertText(string text)
TextInput(text);
}

void IUIKeyInput.DeleteBackward() => KeyPress(Key.Back);
void IUIKeyInput.DeleteBackward() => KeyPress(Key.Back, PhysicalKey.Backspace, "\b");

bool IUIKeyInput.HasText => true;

Expand Down

0 comments on commit 97410ec

Please sign in to comment.