Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

On Linux, KeyEventArgs.KeySymbol is null in KeyDown event for symbols on the number keys

Open PermanentNovice opened this issue 4 months ago • 1 comments

Describe the bug

The code:

textBox.KeyDown+=(s,e)=>
{
 if (e.KeySymbol==null)
 {
  Console.WriteLine("null");
 }
 else
 {
  Console.WriteLine(e.KeySymbol);
 }
};

To reproduce

Type '@' in the text box. On Windows, the console prints '@' as expected. On Linux, it prints 'null'.

The same is true for all the symbols on the keys from 1 to 0.

Expected behavior

Consistent behavior on Windows and Linux.

Environment

  • OS: Windows 11 and Ubuntu 23.10.
  • Avalonia-Version: 11.0.9

PermanentNovice avatar Feb 25 '24 00:02 PermanentNovice

I am not a X11 expert, but it might be null, when XKeysymToString returns empty buffer: https://github.com/AvaloniaUI/Avalonia/blob/d2023a94e8410f9a88314e3404158c9e311fef3c/src/Avalonia.X11/X11Window.Ime.cs#L233-L237

If there is no better X11 API, we might not have much room to improve here.

maxkatz6 avatar Feb 25 '24 01:02 maxkatz6