dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.06k stars 1.73k forks source link

Add Accelerators to all Visual Elements #16202

Open PureWeen opened 1 year ago

PureWeen commented 1 year ago

Description

We've added Accelerators to MenuItems https://github.com/dotnet/maui/issues/5211.

This spec proposes adding Accelerators to VisualElement. WinUI and Catalyst both support Accelerators at the base view level.

This spec is partially in response to https://github.com/dotnet/maui/issues/12004 where Accelerators will give users much more fine-grained control at the view level vs at a global level.

One of the primary reasons to use Accelerators over a Generic keyboard listener, is that this this lets the OS know what KeyCommands you've implemented short cut behavior against. With this information the OS can provide information to readers and better visual hints about available commands.

(Public) API Changes

VisualElement

Properties

API Description
Accelerators Bindable Property that let's you set as many Accelerators as you want.

Usage Scenarios

<StackLayout>
     <StackLayout.Accelerators>
                 <Accelerator Invoked="OnInvoked" Key="f" Modifiers="ctrl+space">
     </StackLayout.Accelertors>
</StackLayout>

Backward Compatibility

N/A

Difficulty

Medium

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

egvijayanand commented 10 months ago

Referring to this issue here: #18782

More details in the comments, AccessKey property.

taublast commented 6 months ago

Why not capture all keyboard keys globally at App level, then every VisualElement can subscribe to them/whatever?
I have a working implementation for such capture in MAUI for Windows and MacCatalist, it could serve as a base. https://github.com/taublast/DrawnUi.Maui/tree/main/src/Engine/Features/Keyboard