fix: NVDA reads the tree entry, slider and help button under the mouse

The tree entry listed the entries under it as its own children, so the controls
inside it lost their way up and Windows failed every lookup there. It now only
points up to the entry it hangs under, which is all the level needs.

The buttons and knob of a slider's track had no name; they now say the slider's
name and value. A button showing only a sign such as "?" takes its tooltip.
This commit is contained in:
maj00r
2026-11-15 19:07:20 +01:00
parent edd530cb4b
commit 95f1cd2398
6 changed files with 75 additions and 22 deletions

View File

@@ -41,14 +41,12 @@ public class ExpandableTreeViewItemTests
}
[Fact]
public void An_entry_on_its_own_has_nothing_under_it_and_nothing_over_it()
public void An_entry_on_its_own_has_nothing_over_it()
{
var item = new ExpandableTreeViewItem { Header = "Całkowo", IsExpanded = true };
var peer = ControlAutomationPeer.CreatePeerForElement(item);
Assert.Empty(item.ReadableChildren);
Assert.Null(item.ReadableParent);
Assert.Empty(peer.GetChildren());
Assert.Null(peer.GetParent());
}
}

View File

@@ -1,4 +1,5 @@
using System.Globalization;
using Avalonia.Automation;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
using Avalonia.Controls;
@@ -8,6 +9,16 @@ namespace StarterNG.Tests;
public class ReadableSliderTests
{
[Fact]
public void The_track_under_the_mouse_says_the_name_and_the_value()
{
var fog = new ReadableSlider { ValueText = "2,4 km" };
Assert.Equal("2,4 km", fog.TrackText);
AutomationProperties.SetName(fog, "Widoczność ");
Assert.Equal("Widoczność: 2,4 km", fog.TrackText);
}
[Fact]
public void A_slider_is_read_as_the_value_shown_beside_it()
{

View File

@@ -69,11 +69,20 @@ public class ScreenReaderNamesTests
{
var button = new Button { Content = new Image() };
ToolTip.SetTip(button, "Pomoc");
button.Content = "?";
button.Content = "Pomoc";
Assert.Null(AutomationProperties.GetName(button));
}
[Fact]
public void A_button_with_only_a_sign_on_it_is_named_by_its_tooltip()
{
var button = new Button { Content = "?" };
ToolTip.SetTip(button, "Pomoc");
Assert.Equal("Pomoc", AutomationProperties.GetName(button));
}
[Fact]
public void A_tree_entry_is_named_by_the_visible_text_of_its_header()
{