Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Handle Numeric AccessKey #16076

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

workgroupengineering
Copy link
Contributor

@workgroupengineering workgroupengineering commented Jun 20, 2024

What does the pull request do?

Handle Numeric AccessKey

What is the current behavior?

Access Key like <Label Content="_1 Oprions"/> does not work

What is the updated/expected behavior with this PR?

Access Key like <Label Content="_1 Oprions"/> work with Numeric Key, does not with Numpad Key

How was the solution implemented (if it's not obvious)?

Using Platform.KeyGestureFormatInfo.FormatKey insteand of Key.ToString()

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #15957

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0049170-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@workgroupengineering workgroupengineering marked this pull request as ready for review June 20, 2024 12:29
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0049179-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@IanRawley
Copy link
Contributor

I don't have a lot of experience with the AccessKey side of things, so I can't comment on why it's done the way it is but I personally feel it would probably be a better idea to register the Key rather than Char in the AccessKeyHandler dictionary and parse the Key once on registration rather than trying to deal with synonyms every time a key is pressed. While this probably handles the numeric AccessKey situation, I suspect it doesn't deal with the non-English AccessKey situation well.

@stevemonaco
Copy link
Contributor

@IanRawley Changing from char to Key would require a breaking change in AccessText.AccessKey, at least for consistency:

public char AccessKey
{
get;
private set;
}

The i18n is probably an issue, too, as you pointed out.

@workgroupengineering workgroupengineering marked this pull request as draft June 21, 2024 09:56
@workgroupengineering
Copy link
Contributor Author

I don't have a lot of experience with the AccessKey side of things, so I can't comment on why it's done the way it is but I personally feel it would probably be a better idea to register the Key rather than Char in the AccessKeyHandler dictionary and parse the Key once on registration rather than trying to deal with synonyms every time a key is pressed. While this probably handles the numeric AccessKey situation, I suspect it doesn't deal with the non-English AccessKey situation well.

I chose KeyGestureFormatInfo because it is extensible.

public sealed class KeyGestureFormatInfo(IReadOnlyDictionary<Key, string>? platformKeyOverrides = null,

In the future we could add in AppBuilder which allows you to configure KeyGestureFormatInfo to solve the problem you expose.

@IanRawley
Copy link
Contributor

@IanRawley Changing from char to Key would require a breaking change in AccessText.AccessKey, at least for consistency:

public char AccessKey
{
get;
private set;
}

The i18n is probably an issue, too, as you pointed out.

Yeah, that's the bit I wasn't aware of. I was just looking at the AccessKeyHandler. If AccessText is pulling the char out of the dictionary, then keeping the dictionary as a char makes sense. If the AccessText is what's feeding the char to AccessKeyHandler to populate the dictionary, then the dictionary could become a Key without breaking anything, but is also less likely to solve all the other issues non-English access keys are likely to cause. I'm specifically thinking Japanese myself, as I have some experience with Japanese keyboards, but not enough with Japanese apps to know if developers are likely to use access keys with Hiragana or Katakana characters.

@workgroupengineering workgroupengineering marked this pull request as ready for review July 17, 2024 10:20
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050218-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050230-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050505-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051029-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051447-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@workgroupengineering
Copy link
Contributor Author

should I make any other changes?

@@ -224,7 +231,10 @@ protected virtual void OnPreviewKeyUp(object? sender, KeyEventArgs e)
{
MainMenu.Open();
}

if (MainMenu is null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to also add || !MainMenu.IsVisible here or combine with pattern matching. If it's not visible, then we currently get the same "sticky" behavior as the original issue where alt is released, but the access keys are still underlined.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0051910-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numeric access keys not working
4 participants