mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
fix: a blind player can bind keys, build a consist and read the tapes
A review against WCAG 2.2 AA left places a screen reader user could not work: - Key bindings: a key's button says the command and the key, the clear button which command it clears; a new key is said aloud and focus comes back to its row. The on-screen keyboard is reached with Tab and walked with the arrows. - Number fields read their label; the spin buttons are named and left out of Tab. - Dialogs: Enter presses the main button, Esc closes, focus starts on the first button and the message is read with it. - Consist: every change is said - added, removed, turned, moved, replaced, undone - and the strip is a named list; a turned card says so. - Searches say how many entries are left once typing pauses. - Hasler tapes, the black box timeline, timetable and cab panel take focus, work from the keyboard, read their value as it changes and draw a focus frame. - Section reset and level controls, the crew button and the tabs carry names; English names from Avalonia's templates are read in the starter's language; sort and crew menus are radio items. - Input borders reach 3:1 against the panels; Tab starts at the top bar; the splash screen has a title and its progress reads the loading step.
This commit is contained in:
47
Eu07.BlackBox.Views/SpokenPeer.cs
Normal file
47
Eu07.BlackBox.Views/SpokenPeer.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using Avalonia.Automation;
|
||||
using Avalonia.Automation.Peers;
|
||||
using Avalonia.Automation.Provider;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Eu07.BlackBox.Views;
|
||||
|
||||
/// <summary>
|
||||
/// What a screen reader is told of a control that draws itself: a name, the moment or
|
||||
/// the row it stands at as its value - read again whenever it changes under the focus,
|
||||
/// as a slider's is - and a description of what it shows or how to work it.
|
||||
/// </summary>
|
||||
internal sealed class SpokenPeer : ControlAutomationPeer, IValueProvider
|
||||
{
|
||||
private readonly AutomationControlType _type;
|
||||
private readonly Func<string?> _value;
|
||||
private readonly Func<string?> _help;
|
||||
|
||||
public SpokenPeer(Control owner, AutomationControlType type, Func<string?> value, Func<string?> help) : base(owner)
|
||||
{
|
||||
_type = type;
|
||||
_value = value;
|
||||
_help = help;
|
||||
}
|
||||
|
||||
/// <summary>Tells the reader the value changed, so it reads the new one.</summary>
|
||||
public void Told(string? before, string? now)
|
||||
{
|
||||
if (before != now)
|
||||
RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, before, now);
|
||||
}
|
||||
|
||||
protected override AutomationControlType GetAutomationControlTypeCore() => _type;
|
||||
|
||||
protected override string? GetHelpTextCore() => base.GetHelpTextCore() is { Length: > 0 } own ? own : _help();
|
||||
|
||||
protected override bool IsContentElementCore() => true;
|
||||
|
||||
protected override bool IsControlElementCore() => true;
|
||||
|
||||
string? IValueProvider.Value => _value();
|
||||
|
||||
bool IValueProvider.IsReadOnly => true;
|
||||
|
||||
void IValueProvider.SetValue(string? value) => throw new InvalidOperationException("The value is read only.");
|
||||
}
|
||||
Reference in New Issue
Block a user