Skip to content

Commit 4b62686

Browse files
author
Bianca Marina Stana
committed
Fixed dropdowns not opening with the screen reader
1 parent 743d80f commit 4b62686

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

Assets/Resources/UITk/MainView.uxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17616599150592)"/>
152152
</Bindings>
153153
</ui:Label>
154-
<ui:Slider high-value="1" name="settingsSoundEffectVolumne">
154+
<ui:Slider high-value="1" name="settingsSoundEffectVolume">
155155
<Bindings>
156156
<ui:DataBinding property="value" data-source-path="soundEffectVolume" binding-mode="TwoWay"/>
157157
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17717329555456)"/>

Assets/Scripts/Localization/LocalizedStringList.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ protected override BindingResult Update(in BindingContext context)
3232
var element = context.targetElement;
3333
var result = GetLocalizedString();
3434
var resultArray = result.Split(separator, System.StringSplitOptions.RemoveEmptyEntries).ToList();
35+
var index = -1;
3536

36-
int index = -1;
37-
if (element is DropdownField)
37+
if (element is DropdownField dropdownField)
3838
{
39-
index = ((DropdownField)element).index;
39+
index = dropdownField.index;
4040
}
4141

4242
if (ConverterGroups.TrySetValueGlobal(ref element, context.bindingId, resultArray, out var errorCode))

Assets/Scripts/Screen Reader/UITk/Handlers/BasePopupFieldHandler.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Unity.Samples.LetterSpell;
21
using UnityEngine.Accessibility;
32
using UnityEngine.Scripting;
43
using UnityEngine.UIElements;
@@ -14,8 +13,6 @@ public BasePopupFieldHandler()
1413
{
1514
selected += () =>
1615
{
17-
ownerElement.schedule.Execute(CheckForOpenedPopupMenu).ExecuteLater(300);
18-
1916
using var evt = NavigationSubmitEvent.GetPooled();
2017
evt.target = ownerElement;
2118
ownerElement.SendEvent(evt);
@@ -98,9 +95,10 @@ void CheckForOpenedPopupMenu()
9895
// if (item.GetAccessibleProperties() != null)
9996
// continue;
10097

101-
var itemAcc = item.GetOrCreateAccessibleProperties();
10298
var itemLabel = item.Q<Label>();
99+
itemLabel.GetOrCreateAccessibleProperties().ignored = true;
103100

101+
var itemAcc = item.GetOrCreateAccessibleProperties();
104102
itemAcc.label = itemLabel != null ? itemLabel.text : $"Item {i}";
105103
itemAcc.role = AccessibilityRole.Button;
106104
itemAcc.state = item.hasCheckedPseudoState ? AccessibilityState.Selected : AccessibilityState.None;
@@ -113,8 +111,6 @@ void CheckForOpenedPopupMenu()
113111
return true;
114112
};
115113

116-
itemLabel.GetOrCreateAccessibleProperties().ignored = true;
117-
118114
i++;
119115
}
120116

Assets/Scripts/Screen Reader/UITk/Handlers/DropdownFieldHandler.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Unity.Samples.LetterSpell;
21
using UnityEngine.Accessibility;
32
using UnityEngine.Scripting;
43
using UnityEngine.UIElements;
@@ -14,8 +13,6 @@ public DropdownFieldHandler()
1413
{
1514
selected += () =>
1615
{
17-
ownerElement.schedule.Execute(CheckForOpenedPopupMenu).ExecuteLater(300);
18-
1916
using var evt = NavigationSubmitEvent.GetPooled();
2017
evt.target = ownerElement;
2118
ownerElement.SendEvent(evt);
@@ -98,9 +95,10 @@ void CheckForOpenedPopupMenu()
9895
// if (item.GetAccessibleProperties() != null)
9996
// continue;
10097

101-
var itemAcc = item.GetOrCreateAccessibleProperties();
10298
var itemLabel = item.Q<Label>();
99+
itemLabel.GetOrCreateAccessibleProperties().ignored = true;
103100

101+
var itemAcc = item.GetOrCreateAccessibleProperties();
104102
itemAcc.label = itemLabel != null ? itemLabel.text : $"Item {i}";
105103
itemAcc.role = AccessibilityRole.Button;
106104
itemAcc.state = item.hasCheckedPseudoState ? AccessibilityState.Selected : AccessibilityState.None;
@@ -113,8 +111,6 @@ void CheckForOpenedPopupMenu()
113111
return true;
114112
};
115113

116-
itemLabel.GetOrCreateAccessibleProperties().ignored = true;
117-
118114
i++;
119115
}
120116

Assets/Scripts/Screen Reader/UITk/Handlers/VisualElementAccessibilityHandler.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,8 @@ public bool isModal
126126
}
127127
}
128128

129-
public virtual bool IsModal()
130-
{
131-
return ownerElement != null && ownerElement.ClassListContains(GenericDropdownMenu.ussClassName);
132-
}
129+
public virtual bool IsModal() => ownerElement != null &&
130+
ownerElement.ClassListContains(GenericDropdownMenu.ussClassName);
133131

134132
public string label
135133
{

0 commit comments

Comments
 (0)