Skip to content

Key is class, and thus passed byref - KittyKeyboardPattern.MapKey needs to make a copy #5067

Description

@tig
private readonly Dictionary<int, Key> _functionalKeyMap = new ()
{
    { 27, Key.Esc },
    { 9, Key.Tab },
    { 13, Key.Enter },
...
};

...

private Key? MapKey (int kittyCode)
{
    if (_functionalKeyMap.TryGetValue (kittyCode, out Key? functionalKey))
    {
        return functionalKey;
    }

...
}

functionalKey returned above is passed all they way up the stack.

In FileDialog (and other places), a key event is cancelled by:

        key.Handled = true;

This corrupts the _functionalKeyMap table making all subsequent keys have Handled = true.

The fix is to:

private Key? MapKey (int kittyCode)
{
    if (_functionalKeyMap.TryGetValue (kittyCode, out Key? functionalKey))
    {
        return new (functionalKey);
    }

...
}

I'll fix this in

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions