Skip to content

Commit 0267b85

Browse files
author
Bianca Marina Stana
committed
Added missing accessibility roles
1 parent 94045bc commit 0267b85

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

Assets/Resources/UITk/MainView.uxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<UnityEngine.Localization.LocalizedString property="placeholderText" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(2876929896448)"/>
9797
</Bindings>
9898
</ui:TextField>
99-
<ui:Label class="settings-header-label">
99+
<ui:Label name="gameplayHeader" class="settings-header-label">
100100
<Bindings>
101101
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(3051354222592)"/>
102102
</Bindings>
@@ -146,7 +146,7 @@
146146
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(36785994493952)"/>
147147
</Bindings>
148148
</UnityEngine.Localization.LanguageSelection>
149-
<ui:Label class="settings-header-label">
149+
<ui:Label name="audioHeader" class="settings-header-label">
150150
<Bindings>
151151
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17616599150592)"/>
152152
</Bindings>
@@ -163,7 +163,7 @@
163163
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17842659553280)"/>
164164
</Bindings>
165165
</ui:Slider>
166-
<ui:Label text="Appearance" class="settings-header-label">
166+
<ui:Label name="appearanceHeader" text="Appearance" class="settings-header-label">
167167
<Bindings>
168168
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(18100730884096)"/>
169169
</Bindings>
@@ -181,7 +181,7 @@
181181
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(19534851502080)"/>
182182
</Bindings>
183183
</ui:Slider>
184-
<ui:Label class="settings-header-label">
184+
<ui:Label name="settingsHeader" class="settings-header-label">
185185
<Bindings>
186186
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(1468861612453888)"/>
187187
</Bindings>

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,16 @@ void EnsureLabelIsNotAccessible()
5151
[Preserve]
5252
class ToggleHandler : BaseFieldHandler<bool>
5353
{
54-
public override AccessibilityRole GetRole()
55-
{
56-
return AccessibilityRole.Toggle;
57-
}
54+
#if UNITY_2023_3_OR_NEWER
55+
public override AccessibilityRole GetRole() => AccessibilityRole.Toggle;
56+
#endif // UNITY_2023_3_OR_NEWER
5857
}
59-
58+
6059
[Preserve]
6160
class RadioButtonHandler : BaseFieldHandler<bool>
6261
{
63-
public override AccessibilityRole GetRole()
64-
{
65-
return AccessibilityRole.Toggle;
66-
}
62+
#if UNITY_2023_3_OR_NEWER
63+
public override AccessibilityRole GetRole() => AccessibilityRole.Toggle;
64+
#endif // UNITY_2023_3_OR_NEWER
6765
}
6866
}

Assets/Scripts/UITk/MainView.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,19 @@ class MainView : MonoBehaviour
216216
Label m_ResultLabel;
217217
Button m_ScreenResultMainMenuButton;
218218
Button m_ScreenResultPlayAgainButton;
219+
219220
VisualElement m_SettingsView;
220221
Button m_CloseSettingsButton;
221222
Button m_SettingsButton;
222223
Button m_InGameSettingsButton;
223-
private TextField m_SearchField;
224+
TextField m_SearchField;
225+
Label m_GameplayHeader;
226+
Label m_AudioHeader;
227+
Label m_AppearanceHeader;
228+
Label m_SettingsHeader;
224229
VisualElement m_LastView;
225230
LetterCardListModel m_Model = new();
226-
231+
227232
// Label m_AnswerLabel;
228233

229234
Gameplay.DifficultyLevel m_SelectedDifficultyLevel = Gameplay.DifficultyLevel.Hard;
@@ -416,15 +421,28 @@ void SetupUI()
416421

417422
m_SettingsView = m_StackView.Q("settingsView");
418423
m_SettingsView.dataSource = m_PlayerSettings;
419-
424+
420425
var settingsScrollView = m_SettingsView.Q<ScrollView>("settingsScrollView");
421426
settingsScrollView.GetOrCreateAccessibleProperties().label = "Settings Scroll View";
422-
427+
423428
m_SearchField = m_SettingsView.Q<TextField>("settingsSearchField");
429+
// TODO: This should be localized.
424430
m_SearchField.GetOrCreateAccessibleProperties().label = "Search";
425431
m_SearchField.GetOrCreateAccessibleProperties().role = AccessibilityRole.SearchField;
426432
m_SearchField.RegisterValueChangedCallback((e) => UpdateSearchField());
427433

434+
m_GameplayHeader = m_SettingsView.Q<Label>("gameplayHeader");
435+
m_GameplayHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
436+
437+
m_AudioHeader = m_SettingsView.Q<Label>("audioHeader");
438+
m_AudioHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
439+
440+
m_AppearanceHeader = m_SettingsView.Q<Label>("appearanceHeader");
441+
m_AppearanceHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
442+
443+
m_SettingsHeader = m_SettingsView.Q<Label>("settingsHeader");
444+
m_SettingsHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
445+
428446
// m_SettingsPopup = new PopupWindow();
429447
// m_SettingsPopup.content = m_SettingsView;
430448

@@ -460,16 +478,16 @@ void SetupUI()
460478

461479
//root.Add(m_AnswerLabel = new Label());
462480
//m_AnswerLabel.style.position = Position.Absolute;
463-
481+
464482
}
465483

466484
void UpdateLangDirection(VisualElement root)
467485
{
468486
if (root.panel == null)
469487
return;
470-
488+
471489
bool isRightToLeft = LocalizationSettings.SelectedLocale?.Identifier.CultureInfo.TextInfo.IsRightToLeft ?? false;
472-
490+
473491
// Update text direction
474492
root.languageDirection = isRightToLeft ? LanguageDirection.RTL : LanguageDirection.LTR;
475493
root.panel.visualTree.EnableInClassList("lsp-dir-ltr", !isRightToLeft);
@@ -629,7 +647,7 @@ void UpdateSearchField()
629647
}
630648

631649
var label = field.Q<Label>();
632-
650+
633651
if (label != null && label.text.ToLowerInvariant().Contains(searchText))
634652
{
635653
field.parent.style.display = DisplayStyle.Flex;

0 commit comments

Comments
 (0)