Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Accessibility: paging keys scroll the turn report, ending, capture dialog and info panel (H3, K6, Fixes #2479) (#2651)

Berif54e65ffb816
diff --git a/changelog.d/2340-paging.md b/changelog.d/2340-paging.md
new file mode 100644
index 000000000..01a2aeb5a
--- /dev/null
+++ b/changelog.d/2340-paging.md
@@ -0,0 +1,5 @@
+### Changed
+
+- PageUp, PageDown, Home and End now scroll the turn report, the end screen, the capture dialog and the map's info
+ panel too, with or without the focus inside them; the topmost open one takes the keys and the map does not move.
+ Their scroll bars are no longer Tab stops (accessibility audit H3, K6; #2479).
diff --git a/docs/accessibility-audit-2026-10-14.md b/docs/accessibility-audit-2026-10-14.md
index 06b84bf2a..0e7dd2e97 100644
--- a/docs/accessibility-audit-2026-10-14.md
+++ b/docs/accessibility-audit-2026-10-14.md
@@ -470,16 +470,17 @@ The reasoning is K3's, not wider: a bar is always in sight, a list is reached by
that hold labels only (`why-rows`, `defence-body`, the event card's text) have nothing to Tab to, while `KeyScroll`
gives PageUp, PageDown, Home and End with or without focus. Focusability only: dragging and the wheel are untouched.
-Three views are left out of the sweep, because for them that reasoning does not hold: `turn-report-rows`,
-`end-screen-rows` and `capture-scroll`. `KeyScroll` has no target for any of them, `GameRoot` switches the paging
-keys off entirely while the turn report or the end screen is open, and their rows are plain labels, so Tab reaches
-nothing inside them. Taking their bar out would leave no keyboard route at all, which is worse than a stray stop.
-Giving `KeyScroll` a route to them is the better answer and is its own change.
+The turn report (`turn-report-rows`), the ending (`end-screen-rows`), the capture dialog (`capture-scroll`) and the
+info panel (`info-panel`) were first left out of the sweep, because `KeyScroll` had no target for them and `GameRoot`
+switched the paging keys off under the turn report and the ending, so their bar was the only keyboard route. Since
+#2479 they take PageUp, PageDown, Home and End through `KeyScroll` too (the topmost of the ending and the turn report
+first, then the capture dialog, then the info panel while it is in reach), `GameRoot` pages under the report and the
+ending, and their bars are out of the Tab order like every other view's. Up and Down still move nothing under the turn
+report or the ending (`GameRoot`'s guard on `NavigationGuard.Step`, L4).
Pinned in EditMode: `ScrollBarTabStopTests` (in a 1280x420 window the Budget's and Defence's bars take no stop,
with the overflow asserted as a precondition so the test cannot pass vacuously; the Cabinet stays at zero; no
-`ScrollView` in the tree keeps a focusable scroller, slider or arrow button apart from the three above; and those
-three do keep theirs, so the exclusion cannot be dropped by accident). No UI string was added, so nothing goes
+`ScrollView` in the tree keeps a focusable scroller, slider or arrow button). No UI string was added, so nothing goes
to #564.
## The focus rule looks past the element's own display, 23 October 2026
diff --git a/unity/Assets/Scripts/UI/FocusScroll.cs b/unity/Assets/Scripts/UI/FocusScroll.cs
index 204e96460..3f04082d5 100644
--- a/unity/Assets/Scripts/UI/FocusScroll.cs
+++ b/unity/Assets/Scripts/UI/FocusScroll.cs
@@ -87,18 +87,8 @@ namespace Statecraft.Game.UI
static bool LaidOut(Rect r) => !float.IsNaN(r.width) && !float.IsNaN(r.height) && r.width > 0f && r.height > 0f;
- /// <summary>The views whose bar is the only way a keyboard player can scroll them, so it stays in the Tab
- /// order. `KeyScroll` gives PageUp, PageDown, Home and End to the open screen's main view and to the decision
- /// card's text, but it has no target for these views (`KeyScroll.MainViews`), and `GameRoot` turns those keys
- /// off entirely while the turn report or the end screen is open (`GameRoot`, the `report?.IsOpen != true &&
- /// end?.IsOpen != true` guard). Their rows are plain labels, so Tab reaches nothing inside them either. Taking
- /// their bar out would leave no way at all to scroll them once they overflow, which is worse than the stray
- /// stop. Giving `KeyScroll` a route to these is the better answer and is its own change; until then they stay
- /// out of the sweep (#41 K6, the owner's review).</summary>
- static readonly string[] OnlyReachableByTheirBar = { "turn-report-rows", "end-screen-rows", "capture-scroll", "info-panel" };
-
/// <summary>Takes every scroll bar under <paramref name="root"/> out of the Tab order (accessibility audit, #41,
- /// K3 widened), except the few in <see cref="OnlyReachableByTheirBar"/>. #1453 did the Cabinet's two views,
+ /// K3 widened). #1453 did the Cabinet's two views,
/// which is where the audit found the stop: the seat list is the one long enough to show its bar in a 1280x720
/// window. Every other view's slider stayed focusable, and a ScrollView hides its scroller only while the
/// content fits, so the stop came back as soon as a view overflowed: a shorter window, or enough content.
@@ -107,13 +97,14 @@ namespace Statecraft.Game.UI
///
/// The same reasoning as K3, no wider: a bar is always in sight and a list is reached by Tabbing its rows, and
/// for the lists that hold labels only (why-rows, defence-body, the event card's text) there is nothing to Tab
- /// to at all, while KeyScroll already gives PageUp, PageDown, Home and End with or without focus. Dragging the
- /// bar and the wheel are untouched: this changes focusability, not behaviour.</summary>
+ /// to at all, while KeyScroll already gives PageUp, PageDown, Home and End with or without focus. The turn
+ /// report, the ending, the capture dialog and the info panel kept their bar until KeyScroll could page them too
+ /// (#41 K6, the owner's review; #2479). Dragging the bar and the wheel are untouched: this changes focusability,
+ /// not behaviour.</summary>
public static void NoScrollBarIsATabStop(VisualElement root)
{
foreach (var view in root.Query<ScrollView>().Build())
- if (System.Array.IndexOf(OnlyReachableByTheirBar, view.name) < 0)
- BarsAreNotTabStops(view);
+ BarsAreNotTabStops(view);
}
/// <summary>Takes a scroll view's own scroll bars out of the Tab order (accessibility audit, #41, the keyboard-only
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index c5f19b358..7249b1d99 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -1230,18 +1230,20 @@ namespace Statecraft.Game.UI
&& capture?.Escape() != true && card?.Escape() != true && card?.CollapsedThisFrame != true)
info?.Escape();
}
- // PageUp, PageDown, Home and End, with no modifier, scroll the open screen or the open card's text, with or without
- // focus (KeyScroll; accessibility audit H3), but not under an End Turn outcome clip, which covers them. The arrows
- // stay with the camera (NavigationGuard, B6), except that Up and Down move between an open screen's rows (audit L4;
- // the owner's answer on #2340, Q27: "do the recommended for all"). The UI map reads no keyboard key (B6), so they
- // arrive here.
+ // PageUp, PageDown, Home and End, with no modifier, scroll the topmost open view (the ending, the turn report, a
+ // screen, the card's text, the capture dialog or the info panel), with or without focus (KeyScroll; accessibility
+ // audit H3, K6), but not under an End Turn outcome clip, which covers them. The arrows stay with the camera
+ // (NavigationGuard, B6), except that Up and Down move between an open screen's rows (audit L4; the owner's answer
+ // on #2340, Q27: "do the recommended for all"). The UI map reads no keyboard key (B6), so they arrive here.
var keys = UnityEngine.InputSystem.Keyboard.current;
- if (keys != null && outcomes?.Showing == null && report?.IsOpen != true && end?.IsOpen != true && !(keys.ctrlKey.isPressed || keys.altKey.isPressed || keys.shiftKey.isPressed || keys.leftMetaKey.isPressed || keys.rightMetaKey.isPressed))
+ if (keys != null && outcomes?.Showing == null && !(keys.ctrlKey.isPressed || keys.altKey.isPressed || keys.shiftKey.isPressed || keys.leftMetaKey.isPressed || keys.rightMetaKey.isPressed))
{
KeyScroll.Key? page = keys.pageUpKey.wasPressedThisFrame ? KeyScroll.Key.PageUp : keys.pageDownKey.wasPressedThisFrame ? KeyScroll.Key.PageDown
: keys.homeKey.wasPressedThisFrame ? KeyScroll.Key.Home : keys.endKey.wasPressedThisFrame ? KeyScroll.Key.End : (KeyScroll.Key?)null;
if (page != null) KeyScroll.Press(document.rootVisualElement, nav?.Current, card?.Shown != null && !card.Collapsed, page.Value);
- if (keys.upArrowKey.wasPressedThisFrame || keys.downArrowKey.wasPressedThisFrame) navGuard?.Step(keys.upArrowKey.wasPressedThisFrame);
+ // Not under the turn report or the ending: they cover the screen, which ScreenNav.DisableCovered leaves enabled (#2651 review).
+ if (report?.IsOpen != true && end?.IsOpen != true && (keys.upArrowKey.wasPressedThisFrame || keys.downArrowKey.wasPressedThisFrame))
+ navGuard?.Step(keys.upArrowKey.wasPressedThisFrame);
}
SyncMinimap();
if (!logCamera || rig == null || (rig.Distance == loggedDistance && rig.Yaw == loggedYaw)) return;
diff --git a/unity/Assets/Scripts/UI/KeyScroll.cs b/unity/Assets/Scripts/UI/KeyScroll.cs
index eab7afda5..a433a94a6 100644
--- a/unity/Assets/Scripts/UI/KeyScroll.cs
+++ b/unity/Assets/Scripts/UI/KeyScroll.cs
@@ -8,7 +8,9 @@ namespace Statecraft.Game.UI
/// <summary>PageUp, PageDown, Home and End scroll the open screen, or the open decision card's text, from the keyboard
/// (accessibility audit H3, #41). The Why list, the event text and the Defence body hold labels only, so Tab never
/// reaches into them, and the arrows pan the camera (NavigationGuard, ruling B6; Up and Down reach only an open screen's
- /// controls, audit L4). GameRoot polls the keys beside its Escape poll, so they work with or without focus.</summary>
+ /// controls, audit L4). GameRoot polls the keys beside its Escape poll, so they work with or without focus. The ending,
+ /// the turn report, the capture dialog and the info panel are labels too, so they get the keys as well (H3, K6, #2479),
+ /// and their bars leave the Tab order (FocusScroll.NoScrollBarIsATabStop).</summary>
public static class KeyScroll
{
public enum Key { PageUp, PageDown, Home, End }
@@ -27,7 +29,8 @@ namespace Statecraft.Game.UI
/// <summary>Scrolls the target view one page up or down, or to its top or bottom; false when there is no target or
/// it is already there. The target: the ScrollView around the focused element if that is inside the open screen,
/// else the open screen's main view, else (no screen open) the decision card's text while the card is open and not
- /// hidden. Nothing while the start screen shows.</summary>
+ /// hidden, else the capture dialog's while it shows, else the info panel while it is in reach. Over all of those, the
+ /// topmost of the ending and the turn report. Nothing while the start screen shows.</summary>
public static bool Press(VisualElement root, string? screen, bool cardOpen, Key key)
{
var view = Target(root, screen, cardOpen);
@@ -45,7 +48,18 @@ namespace Statecraft.Game.UI
{
if ((root.Q("root") ?? root).ClassListContains(OpeningPresenter.OpenClass)) return root.Q<ScrollView>("opening-scroll");
if ((root.Q("root") ?? root).ClassListContains(StartScreenPresenter.OpenClass)) return null;
- if (screen == null) return cardOpen ? root.Q<ScrollView>("event-scroll") : null;
+ // Topmost first, the order Escape closes them in (GameRoot.Update): the ending is over the turn report, and both
+ // cover the screens, the card, the capture dialog and the info panel (ScreenNav.DisableCovered).
+ if ((root.Q("root") ?? root).ClassListContains(EndScreenPresenter.OpenClass)) return root.Q<ScrollView>("end-screen-rows");
+ if ((root.Q("root") ?? root).ClassListContains(TurnReportPresenter.OpenClass)) return root.Q<ScrollView>("turn-report-rows");
+ if (screen == null)
+ {
+ if (cardOpen) return root.Q<ScrollView>("event-scroll");
+ if ((root.Q("root") ?? root).ClassListContains(CaptureDialogPresenter.OpenClass)) return root.Q<ScrollView>("capture-scroll");
+ // A modal, a wide screen or the start screen disables the panel (ScreenNav.DisableCovered); the USS hides it.
+ var info = root.Q<ScrollView>("info-panel");
+ return info != null && info.enabledInHierarchy && info.resolvedStyle.display != DisplayStyle.None ? info : null;
+ }
var open = root.Q<VisualElement>("screen-" + screen);
var around = (root.panel?.focusController?.focusedElement as VisualElement)?.GetFirstAncestorOfType<ScrollView>();
if (around != null && open != null && open.Contains(around)) return around;
diff --git a/unity/Assets/Tests/EditMode/FocusScrollTests.cs b/unity/Assets/Tests/EditMode/FocusScrollTests.cs
index baeeade01..1a4530324 100644
--- a/unity/Assets/Tests/EditMode/FocusScrollTests.cs
+++ b/unity/Assets/Tests/EditMode/FocusScrollTests.cs
@@ -75,6 +75,8 @@ public class FocusScrollTests
using (var e = NavigationMoveEvent.GetPooled(NavigationMoveEvent.Direction.Next)) { e.target = from; from.SendEvent(e); }
}
+ /// <summary>H3, K6 (#2479): the info panel's label-only facts page from the keyboard (KeyScroll), so its bar is out
+ /// of the Tab order like every other; once a screen covers the panel the keys go to the screen and the facts stay.</summary>
[UnityTest]
public IEnumerator TheInfoPanelsLabelOnlyOverflowIsKeyboardReachableUntilCovered()
{
@@ -98,26 +100,17 @@ public class FocusScrollTests
FocusScroll.NoScrollBarIsATabStop(r.Root); // The policy GameRoot applies after constructing the views.
yield return Frames(4);
var slider = view.verticalScroller.slider;
- Assert.IsTrue(slider.focusable, "label-only facts retain a keyboard scroll stop");
+ Assert.IsFalse(slider.focusable, "the facts' bar is no Tab stop: the paging keys reach them");
Assert.Greater(view.verticalScroller.highValue, 0f, "precondition: the facts overflow");
Assert.IsFalse(Inside(last, view), "precondition: the bottom fact is below the viewport");
before.Focus();
- for (int i = 0; i < 8 && r.Focused != slider; i++)
- {
- Tab((VisualElement)r.Focused!);
- yield return Frames(1);
- }
- Assert.AreSame(slider, r.Focused, "Tab reaches the info panel's slider with no card or screen open");
- using (var key = KeyDownEvent.GetPooled(new Event { type = EventType.KeyDown, keyCode = KeyCode.End }))
- { key.target = slider; slider.SendEvent(key); }
+ Assert.IsTrue(KeyScroll.Press(r.Root, null, false, KeyScroll.Key.End), "End with no card or screen open scrolls the facts");
yield return Frames(3);
- Assert.IsTrue(Inside(last, view), "End on the slider reaches the bottom label");
+ Assert.IsTrue(Inside(last, view), "End reaches the bottom label");
nav.Open("cabinet");
- before.Focus();
- Assert.IsFalse(slider.canGrabFocus, "the covered slider cannot take keyboard focus");
+ yield return Frames(2);
float coveredOffset = view.scrollOffset.y;
- using (var key = KeyDownEvent.GetPooled(new Event { type = EventType.KeyDown, keyCode = KeyCode.Home }))
- { key.target = slider; slider.SendEvent(key); }
+ KeyScroll.Press(r.Root, "cabinet", false, KeyScroll.Key.Home);
yield return Frames(2);
Assert.AreEqual(coveredOffset, view.scrollOffset.y, "keys cannot scroll the covered facts");
}
diff --git a/unity/Assets/Tests/EditMode/KeyScrollTests.cs b/unity/Assets/Tests/EditMode/KeyScrollTests.cs
index 59810dff2..d7e69fc50 100644
--- a/unity/Assets/Tests/EditMode/KeyScrollTests.cs
+++ b/unity/Assets/Tests/EditMode/KeyScrollTests.cs
@@ -2,13 +2,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using NUnit.Framework;
using Statecraft.Game;
+using Statecraft.Game.Map;
using Statecraft.Game.UI;
using Statecraft.Sim;
using UnityEditor;
+using UnityEditor.SceneManagement;
using UnityEngine;
+using UnityEngine.InputSystem;
+using UnityEngine.InputSystem.LowLevel;
using UnityEngine.TestTools;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;
@@ -170,6 +175,107 @@ public class KeyScrollTests
PagesThrough(r.Root, text, null, true, "event text");
}
+ /// <summary>A game on its last day, ended as the MVP ends (as EndScreenTests.Ended), so the end screen opens.</summary>
+ static GameSession Ended()
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.Date = C.End; g.State.GameOver = GameOverCodes.MvpEnded;
+ return g;
+ }
+
+ /// <summary>H3, K6 (#2479): the turn report's rows page from the keyboard; its rows are labels, so Tab never reaches them.</summary>
+ [UnityTest]
+ public IEnumerator ThePageKeysScrollTheTurnReportH3K6()
+ {
+ using var r = new Rig();
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);
+ var nav = r.Own(new ScreenNav(r.Root));
+ var report = r.Own(new TurnReportPresenter(r.Root, bridge, Text, nav));
+ bridge.EndTurn();
+ var rows = r.Root.Q<ScrollView>("turn-report-rows");
+ Shorten(rows, 16f);
+ yield return Frames(4);
+ Assert.IsTrue(report.IsOpen, "precondition: the report is open");
+ PagesThrough(r.Root, rows, null, false, "turn report");
+ }
+
+ /// <summary>H3, K6 (#2479): the ending's rows page from the keyboard.</summary>
+ [UnityTest]
+ public IEnumerator ThePageKeysScrollTheEndingH3K6()
+ {
+ using var r = new Rig();
+ var end = r.Own(new EndScreenPresenter(r.Root, new SimBridge(Ended(), Text), Text, null));
+ var rows = r.Root.Q<ScrollView>("end-screen-rows");
+ Shorten(rows, 16f);
+ yield return Frames(4);
+ Assert.IsTrue(end.IsOpen, "precondition: the end screen is open");
+ PagesThrough(r.Root, rows, null, false, "ending");
+ }
+
+ /// <summary>H3, K6 (#2479): the capture dialog's text and options page from the keyboard while it shows, and the info
+ /// panel's facts page while no dialog, card or screen covers it.</summary>
+ [UnityTest]
+ public IEnumerator ThePageKeysScrollTheCaptureDialogThenTheInfoPanelH3K6()
+ {
+ using var r = new Rig();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ g.State.PendingEvents.Clear();
+ g.State.Settlements["lod"] = new SettlementControl(Movement.PlayerSide, SettlementControl.AwaitingChoice, g.State.Date);
+ var bridge = new SimBridge(g, Text);
+ r.Own(new ScreenNav(r.Root));
+ var info = r.Own(new InfoPanelPresenter(r.Root, bridge, Text, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)));
+ var card = r.Own(new EventCardPresenter(r.Root, bridge, Text, null));
+ var dialog = r.Own(new CaptureDialogPresenter(r.Root, bridge, Text, card, new Dictionary<string, string>()));
+ var text = r.Root.Q<ScrollView>("capture-scroll");
+ Shorten(text, 16f);
+ yield return Frames(4);
+ Assert.AreEqual("lod", dialog.Shown, "precondition: the dialog shows");
+ PagesThrough(r.Root, text, null, false, "capture dialog");
+
+ dialog.Collapse(takeFocus: false);
+ var hex = C.SettlementHexes.First(x => x.Id == "tel_aviv");
+ info.Show(hex.Q, hex.R);
+ var panel = r.Root.Q<ScrollView>("info-panel");
+ Shorten(panel, 16f);
+ yield return Frames(4);
+ Assert.IsTrue(panel.enabledInHierarchy, "precondition: nothing covers the info panel");
+ PagesThrough(r.Root, panel, null, false, "info panel");
+ }
+
+ /// <summary>H3, K6 (#2479): the topmost open view takes the keys: the ending over the turn report, the report over an
+ /// open screen, and nothing under them moves.</summary>
+ [UnityTest]
+ public IEnumerator TheTopmostOpenViewTakesThePageKeysH3K6()
+ {
+ using var r = new Rig();
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var bridge = new SimBridge(g, Text);
+ var nav = r.Own(new ScreenNav(r.Root));
+ r.Own(new WhyPresenter(r.Root, bridge, Text));
+ var report = r.Own(new TurnReportPresenter(r.Root, bridge, Text, nav));
+ bridge.Queue(new SetMobilization(1.0));
+ bridge.EndTurn();
+ nav.Open("why");
+ var why = r.Root.Q<ScrollView>("why-rows"); var rows = r.Root.Q<ScrollView>("turn-report-rows");
+ Shorten(why, 40f); Shorten(rows, 16f);
+ yield return Frames(4);
+ Assert.IsTrue(report.IsOpen, "precondition: the report is open over the Why screen");
+ Assert.Greater(why.verticalScroller.highValue, 0f, "precondition: the Why list overflows too");
+ PagesThrough(r.Root, rows, "why", false, "report over a screen");
+ Assert.IsTrue(KeyScroll.Press(r.Root, "why", false, KeyScroll.Key.End), "End under the report");
+ Assert.AreEqual(0f, why.scrollOffset.y, 0.5f, "the screen under the report did not move");
+
+ g.State.Date = C.End; g.State.GameOver = GameOverCodes.MvpEnded;
+ var end = r.Own(new EndScreenPresenter(r.Root, bridge, Text, null));
+ var ending = r.Root.Q<ScrollView>("end-screen-rows");
+ Shorten(ending, 16f);
+ rows.scrollOffset = Vector2.zero;
+ yield return Frames(4);
+ Assert.IsTrue(end.IsOpen && report.IsOpen, "precondition: the ending is open over the report");
+ PagesThrough(r.Root, ending, "why", false, "ending over the report");
+ Assert.AreEqual(0f, rows.scrollOffset.y, 0.5f, "the report under the ending did not move");
+ }
+
[UnityTest]
public IEnumerator NothingScrollsUnderTheStartScreen()
{
@@ -189,3 +295,85 @@ public class KeyScrollTests
Assert.AreEqual(0f, rows.scrollOffset.y, 0.5f, "the list did not move");
}
}
+
+/// <summary>H3, K6 (#2479) through GameRoot's own key poll: PageDown and Home, pressed as real keys, page the open turn report
+/// with the focus on its Close button and with no focus at all, and the camera does not move.</summary>
+public class KeyScrollThroughGameRootTests : SharedCameraActionsFixture
+{
+ string saveDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+
+ [SetUp] public void TempSaves() => saveDir = Path.Combine(Path.GetTempPath(), "statecraft-keyscroll-" + Guid.NewGuid().ToString("N"));
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ if (ps != null) Object.DestroyImmediate(ps);
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
+ }
+
+ static void Send(MonoBehaviour c, string message) =>
+ c.GetType().GetMethod(message, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.Invoke(c, null);
+
+ [UnityTest]
+ public IEnumerator ThePageKeysPageTheOpenTurnReportAndLeaveTheMapH3K6()
+ {
+ // The keys as state events: the fixture's Press (Set) does not run in an edit-mode [UnityTest], and the boot needs frames.
+ InputSystem.actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");
+ var keyboard = InputSystem.AddDevice<Keyboard>();
+ // Warm the keys: wasPressedThisFrame can miss a press on its first call ever (as in MapPointerTickTests).
+ _ = keyboard.pageDownKey.wasPressedThisFrame; _ = keyboard.homeKey.wasPressedThisFrame;
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ rt = new RenderTexture(1280, 720, 0);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt;
+ doc.panelSettings = ps;
+ Object.FindFirstObjectByType<MapScene>().Build(MapFocusTests.Inputs.Map);
+ var root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ root.Begin(MapFocusTests.Inputs, 0);
+ var ui = doc.rootVisualElement;
+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;
+ for (int i = 0; i < 5; i++) yield return null;
+ GameSceneTests.HideTheOpeningCard(ui);
+ root.Bridge!.EndTurn();
+ var rows = ui.Q<ScrollView>("turn-report-rows");
+ rows.style.height = 16f; rows.style.minHeight = 16f; rows.style.maxHeight = 16f; rows.style.flexGrow = 0;
+ for (int i = 0; i < 5; i++) yield return null;
+ Assert.IsTrue(ui.Q("root").ClassListContains(TurnReportPresenter.OpenClass), "precondition: the turn report is open");
+ Assert.Greater(rows.verticalScroller.highValue, 24f, "precondition: the report's rows overflow by more than a line");
+ var cam = Object.FindFirstObjectByType<CameraController>();
+ var rig = cam.GetComponent<CameraRig>();
+ Send(cam, "Awake"); Send(cam, "OnEnable");
+ try
+ {
+ // One frame with the key down: GameRoot's poll (Update) and the camera's (Tick) both read it.
+ void Hold(UnityEngine.InputSystem.Key k)
+ {
+ var from = rig.LookAt; float distance = rig.Distance, yaw = rig.Yaw;
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState(k)); InputSystem.Update();
+ Assert.IsTrue(keyboard[k].wasPressedThisFrame, "precondition: " + k + " went down this frame");
+ Send(root, "Update");
+ for (int i = 0; i < 5; i++) cam.Tick(0.1f);
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState()); InputSystem.Update();
+ cam.Tick(0.1f);
+ Assert.AreEqual(from, rig.LookAt, k + ": the map does not pan");
+ Assert.AreEqual(distance, rig.Distance, k + ": the map does not zoom");
+ Assert.AreEqual(yaw, rig.Yaw, k + ": the map does not turn");
+ }
+ var close = ui.Q<Button>("turn-report-close");
+ close.Focus();
+ Assert.AreSame(close, ui.panel.focusController.focusedElement, "precondition: the report's Close has the focus");
+ Hold(UnityEngine.InputSystem.Key.PageDown);
+ Assert.Greater(rows.scrollOffset.y, 0f, "PageDown, focus on Close: the report's rows moved");
+ close.Blur();
+ Assert.IsNull(ui.panel.focusController.focusedElement, "precondition: nothing has the focus");
+ Hold(UnityEngine.InputSystem.Key.Home);
+ Assert.AreEqual(0f, rows.scrollOffset.y, 0.5f, "Home, no focus: back at the top");
+ }
+ finally { Send(cam, "OnDisable"); }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/ScreenRowArrowTests.cs b/unity/Assets/Tests/EditMode/ScreenRowArrowTests.cs
index d107cd8d0..8c231e850 100644
--- a/unity/Assets/Tests/EditMode/ScreenRowArrowTests.cs
+++ b/unity/Assets/Tests/EditMode/ScreenRowArrowTests.cs
@@ -222,6 +222,85 @@ public class ScreenRowArrowTests : SharedCameraActionsFixture
finally { Send(cam, "OnDisable"); }
}
+ /// <summary>L4 under the turn report (#2651 review): the real Up and Down keys, read by GameRoot's poll, move no focus while
+ /// the report is open. The report closes the screen it opens over (TurnReportPresenter: nav.Close), so first nothing is
+ /// under it; then a screen is opened under it directly (the ending, for one, closes none), and the keys still leave the
+ /// focus where the report put it, since the report covers that screen.</summary>
+ [UnityTest]
+ public IEnumerator UpAndDownMoveNothingUnderTheTurnReportL4()
+ {
+ InputSystem.actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");
+ var keyboard = InputSystem.AddDevice<Keyboard>();
+ _ = keyboard.upArrowKey.wasPressedThisFrame; _ = keyboard.downArrowKey.wasPressedThisFrame; // warm, as above
+ yield return Boot();
+ yield return Open("budget");
+ var lines = ui.Q<ScrollView>("budget-rows").contentContainer.Children().Where(r => r.Q<Button>(r.name + "-down") != null).ToList();
+ yield return Focus(lines[0].name + "-down");
+ root.Bridge!.EndTurn();
+ yield return Frames(5);
+ Assert.IsTrue(ui.Q("root").ClassListContains(TurnReportPresenter.OpenClass), "precondition: the turn report is open");
+ Assert.AreEqual(DisplayStyle.None, ui.Q("screen-budget").resolvedStyle.display, "the report closed the Budget it opened over");
+ void Keys(string when)
+ {
+ var at = FocusedName;
+ foreach (var k in new[] { UnityEngine.InputSystem.Key.DownArrow, UnityEngine.InputSystem.Key.UpArrow, UnityEngine.InputSystem.Key.DownArrow })
+ {
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState(k)); InputSystem.Update();
+ Assert.IsTrue(keyboard[k].wasPressedThisFrame, "precondition: " + k + " went down this frame");
+ Send(root, "Update");
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState()); InputSystem.Update();
+ Assert.AreEqual(at, FocusedName, k + " " + when + " left the focus where it was");
+ }
+ }
+ Keys("under the report");
+ var nav = (ScreenNav)typeof(GameRoot).GetField("nav", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.GetValue(root)!;
+ nav.Open("budget");
+ yield return Frames(5);
+ Assert.IsTrue(ui.Q("root").ClassListContains(TurnReportPresenter.OpenClass), "precondition: the report is still open");
+ Assert.AreEqual("budget", nav.Current, "precondition: the Budget is open under the report");
+ Assert.AreEqual(DisplayStyle.Flex, ui.Q("screen-budget").resolvedStyle.display, "precondition: the Budget's rows show, so Step could reach them");
+ Keys("with the Budget under the report");
+ Assert.AreEqual(0, presses, "no key pressed a button");
+ }
+
+ /// <summary>L4 under the ending (#2651 review): the end screen closes no screen (EndScreenPresenter.Show), so a screen
+ /// can be open under it, yet the real Up and Down keys, read by GameRoot's poll, leave the focus where the ending put it.
+ /// The game ends through the bridge; the turn report that opens with it (and closes the Budget) is closed, so only the
+ /// ending is over the Budget, opened again under it.</summary>
+ [UnityTest]
+ public IEnumerator UpAndDownMoveNothingUnderTheEndingL4()
+ {
+ InputSystem.actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");
+ var keyboard = InputSystem.AddDevice<Keyboard>();
+ _ = keyboard.upArrowKey.wasPressedThisFrame; _ = keyboard.downArrowKey.wasPressedThisFrame; // warm, as above
+ yield return Boot();
+ var bridge = root.Bridge!;
+ bridge.State.Date = bridge.Content.End; bridge.State.GameOver = Statecraft.Sim.GameOverCodes.MvpEnded; // as EndScreenTests.Ended
+ bridge.EndTurn();
+ yield return Frames(5);
+ var hud = ui.Q("root");
+ Assert.IsTrue(hud.ClassListContains(EndScreenPresenter.OpenClass), "precondition: the end screen is open");
+ const System.Reflection.BindingFlags Private = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
+ ((TurnReportPresenter?)typeof(GameRoot).GetField("report", Private)!.GetValue(root))?.Close();
+ ((ScreenNav)typeof(GameRoot).GetField("nav", Private)!.GetValue(root)!).Open("budget");
+ yield return Frames(5);
+ Assert.IsTrue(hud.ClassListContains(EndScreenPresenter.OpenClass), "precondition: the end screen is still open");
+ Assert.IsFalse(hud.ClassListContains(TurnReportPresenter.OpenClass), "precondition: no turn report, so only the ending guards");
+ Assert.IsFalse(hud.ClassListContains(OutcomePresenter.OpenClass), "precondition: no outcome clip, which skips the whole poll");
+ Assert.IsTrue(hud.ClassListContains(ScreenNav.ScreenOpenClass), "precondition: the Budget is still open under the ending");
+ Assert.AreEqual(DisplayStyle.Flex, ui.Q("screen-budget").resolvedStyle.display, "precondition: the Budget's rows show, so Step could reach them");
+ var at = FocusedName;
+ foreach (var k in new[] { UnityEngine.InputSystem.Key.DownArrow, UnityEngine.InputSystem.Key.UpArrow, UnityEngine.InputSystem.Key.DownArrow })
+ {
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState(k)); InputSystem.Update();
+ Assert.IsTrue(keyboard[k].wasPressedThisFrame, "precondition: " + k + " went down this frame");
+ Send(root, "Update");
+ InputSystem.QueueStateEvent(keyboard, new KeyboardState()); InputSystem.Update();
+ Assert.AreEqual(at, FocusedName, k + " under the ending left the focus where it was");
+ }
+ Assert.AreEqual(0, presses, "no key pressed a button");
+ }
+
static void Send(MonoBehaviour c, string message) =>
c.GetType().GetMethod(message, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.Invoke(c, null);
diff --git a/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs
index 61aba88a9..54c31b8e9 100644
--- a/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs
+++ b/unity/Assets/Tests/EditMode/ScrollBarTabStopTests.cs
@@ -23,8 +23,8 @@ using Object = UnityEngine.Object;
/// views overflow and their bars are really in the order. Defence is the worst case: it has no control of its own at
/// the opening turn, so its bar is very nearly the only thing a keyboard player can land on.
///
-/// `turn-report-rows`, `end-screen-rows` and `capture-scroll` are deliberately not swept: their bar is the only way a
-/// keyboard player can scroll them, and that exclusion is pinned below so it cannot be dropped by accident.</summary>
+/// The turn report, the ending, the capture dialog and the info panel are swept too, now that KeyScroll pages them (#2479,
+/// #41 K6, KeyScrollTests).</summary>
public class ScrollBarTabStopTests
{
string saveDir = "";
@@ -139,19 +139,15 @@ public class ScrollBarTabStopTests
Assert.IsEmpty(found, $"the Cabinet's bars stay out of the order, but one lap stopped on: {string.Join(", ", found)}");
}
- /// <summary>Every ScrollView in the tree has both of its bars out of the order, except the four whose bar is the
- /// only way a keyboard player can scroll them. `KeyScroll` has no target for `turn-report-rows`,
- /// `end-screen-rows`, `capture-scroll` or `info-panel` (its facts are labels, #40), and `GameRoot` switches PageUp, PageDown, Home and End off entirely
- /// while the report or the end screen is open, so taking their bar out would leave no keyboard route at all.</summary>
+ /// <summary>Every ScrollView in the tree has both of its bars out of the order, the turn report's, the ending's, the
+ /// capture dialog's and the info panel's included: KeyScroll pages those from the keyboard (#2479, K6).</summary>
[UnityTest]
public IEnumerator NoScrollViewInTheTreeKeepsAFocusableBar()
{
yield return BootShort();
- var exempt = new[] { "turn-report-rows", "end-screen-rows", "capture-scroll", "info-panel" };
var bad = new List<string>();
foreach (var sv in ui.Query<ScrollView>().Build())
{
- if (System.Array.IndexOf(exempt, sv.name) >= 0) continue;
// both bars, as the helper itself sets: "every scroll bar" means the horizontal one too
foreach (var (which, s) in new[] { ("vertical", sv.verticalScroller), ("horizontal", sv.horizontalScroller) })
{
@@ -165,20 +161,4 @@ public class ScrollBarTabStopTests
}
Assert.IsEmpty(bad, $"these scroll bars can still take the focus: {string.Join(", ", bad)}");
}
-
- /// <summary>The exclusion is deliberate, so it is pinned: the four views the keyboard cannot otherwise scroll
- /// keep a focusable bar. If `KeyScroll` is ever given a route to them, this test should be deleted along with the
- /// exclusion in `FocusScroll.OnlyReachableByTheirBar` (#41 K6, the owner's review).</summary>
- [UnityTest]
- public IEnumerator TheViewsTheKeyboardCannotOtherwiseScrollKeepTheirBar()
- {
- yield return BootShort();
- foreach (var name in new[] { "turn-report-rows", "end-screen-rows", "capture-scroll", "info-panel" })
- {
- var sv = ui.Q<ScrollView>(name);
- Assert.IsNotNull(sv, $"precondition: {name} is in the tree");
- Assert.IsTrue(sv.verticalScroller.slider.focusable,
- $"{name} has no keyboard scroll route but its bar, so the bar stays reachable");
- }
- }
}