Skip to content

Conversation

@PureWeen
Copy link
Collaborator

@PureWeen PureWeen commented Apr 11, 2025

Description

Current observations with regards to creating a Composite Button out of a "Content View" that works with keyboard

  1. Currently MAUI doesn't propagate Focus changes from a basic MauiView up to the xplat code. I've created an issue here so that if focus behavior has been enabled then you can use a VSM for style changes. I've hacked around this in this PR for now to demonstrate the behavior

  2. Generally a Content View works fine for keyboard navigation if you've setup the expectations correctly. If you add a SemanticDescription to a contentview this causes it to become part of the accessibility tree. This means that if you enable basic keyboard enhancement features on MAC you'll be able to navigate to the Content View with a keyboard.

As a note, this is also how UIButton works.

If you build a basic swift app, you won't be able to navigate to this button.

image

Once you enable Keyboard Navigation in the Keyboard Settings on your mac (Settings => Keyboard => Keyboard SEttings => Keyboard Navigation) then it works fine.

  1. If you want to be able to navigate to the ContentView without enabling Keyboard Navigation you can override the "CanBecomeFocused" property on the ContentView and return true. This is not really recommended though because other interactive controls aren't going to work like this either. For example, any native control (UIButton) will still be unreachable with a keyboard unless you enable keyboard navigation.

@PureWeen PureWeen closed this May 22, 2025
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.

2 participants