Giter Site home page Giter Site logo

Numeric access keys not working about avalonia HOT 1 OPEN

JouriM2 avatar JouriM2 commented on September 27, 2024
Numeric access keys not working

from avalonia.

Comments (1)

stevemonaco avatar stevemonaco commented on September 27, 2024

Moving some details from the originating discussion...

For point 1:

protected virtual void OnKeyDown(object? sender, KeyEventArgs e)
{
bool menuIsOpen = MainMenu?.IsOpen == true;
if (e.KeyModifiers.HasAllFlags(KeyModifiers.Alt) && !e.KeyModifiers.HasAllFlags(KeyModifiers.Control) || menuIsOpen)
{
// If any other key is pressed with the Alt key held down, or the main menu is open,
// find all controls who have registered that access key.
var text = e.Key.ToString();

e.Key.ToString() returns "D1" for the key (because of the enum) whereas "_1 One" registers "1" in the hotkey map.

For point 2:

This works as expected if you have a Menu, which is the primary use of AccessText. I'm not sure what the intended design is for out-of-menu access keys. You should be able to press the alt key, release it, and continue pressing access keys (with or without alt held down) to navigate. The non-menu access keys return to normal when the menu is closed.

It can be fixed in this area

protected virtual void OnPreviewKeyUp(object? sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.LeftAlt:
case Key.RightAlt:
_altIsDown = false;
if (_ignoreAltUp)
{
_ignoreAltUp = false;
}
else if (_showingAccessKeys && MainMenu != null)
{
MainMenu.Open();
}
break;
}
}
by placing the following before the break;. Not sure if there are any side-effects.

if (MainMenu is null)
{
    _owner!.ShowAccessKeys = _showingAccessKeys = false;
}

from avalonia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.