[PR #5348] [MERGED] Navigate menus with Tab, the arrows and Enter as vanilla does #6230

Closed
opened 2026-11-03 06:16:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5348
Author: @leifiyoo
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: narrator/15-keyboard-focus


📝 Commits (10+)

  • 37313e8 Narrate World Options' switches and lock, and the stats lists
  • 6fd6a9b Narrate the recipe book as RecipeBookComponent does
  • 8049680 Leave inactive edit boxes out and keep the book button's focus
  • a60214a Document the narrator
  • 741cc76 Narrate options lists, key binds, pack lists and dialogs as vanilla does
  • bbbdd3d Narrate game rules and command block switches as CycleButtons
  • 9171f3b Let horizon-ctl's keys and typing reach the screen narration
  • 27f9488 Navigate menus with Tab, the arrows and Enter as vanilla does
  • bc79141 List two more narrator differences found end to end
  • 3c46c26 Document keyboard focus navigation

📊 Changes

22 files changed (+2526 additions, -224 deletions)

View changed files

📝 crates/horizon-client-render/src/options_ui.rs (+334 -85)
📝 crates/horizon-client-render/src/pack_screen.rs (+47 -6)
📝 crates/horizon-client-render/src/ui.rs (+21 -3)
📝 crates/horizon-client-render/src/widgets.rs (+102 -9)
📝 crates/horizon-client/src/game.rs (+22 -3)
📝 crates/horizon-client/src/game/command_blocks.rs (+126 -1)
📝 crates/horizon-client/src/game/control.rs (+4 -0)
📝 crates/horizon-client/src/game/dialogs.rs (+71 -0)
➕ crates/horizon-client/src/game/key_focus.rs (+473 -0)
📝 crates/horizon-client/src/game/lan_screen.rs (+195 -1)
📝 crates/horizon-client/src/game/narrator.rs (+20 -12)
📝 crates/horizon-client/src/game/pad.rs (+2 -0)
📝 crates/horizon-client/src/game/pad_menu.rs (+427 -61)
📝 crates/horizon-client/src/game/recipe_book.rs (+98 -3)
📝 crates/horizon-client/src/game/stats_screen.rs (+104 -31)
📝 crates/horizon-client/src/game_rules_screen.rs (+100 -1)
📝 crates/horizon-client/src/recipe_book_screen.rs (+1 -1)
📝 crates/horizon-client/src/screen_narrator.rs (+124 -7)
📝 crates/horizon-client/src/title.rs (+45 -0)
📝 docs/README.md (+1 -0)

...and 2 more files

📄 Description

🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo.

Part 15 of 16 of the narrator series. All 16 PRs have to be merged, in this order, for the narrator to work completely: #5333 → #5334 → #5335 → #5336 → #5337 → #5338 → #5339 → #5340 → #5341 → #5342 → #5343 → #5344 → #5346 → #5347 → #5348 → #5349. Each PR builds on the one before it (stacked branches), so until the previous one is merged this PR's diff also shows its commits; merging only some of them, or out of order, leaves the narrator unfinished.

Stacked on #5347 — merge that first; until then this PR also shows its commits.

Menus can now be used with the keyboard as in vanilla: Tab / Shift+Tab move the focus, the arrows move it by direction, Enter / Space / keypad Enter press the focused widget. The narrator reads the focused widget, which makes the menus usable without a mouse.

What vanilla does

Screen.keyPressed: Tab → FocusNavigationEvent.TabNavigation, arrows → ArrowNavigation (ScreenRectangle-based nextFocusPathInDirection), Enter/Space activate the focused widget; sliders follow canChangeValue, EditBox keeps its caret keys, a list is one Tab stop; the world list selects its focused row.

What changed

  • crates/horizon-client/src/game/key_focus.rs (new): Tab order, the ported directional step, which keys a focused widget keeps.
  • crates/horizon-client/src/game/pad_menu.rs, pad.rs: the controller's focus targets shared with the keyboard; the keyboard's hidden pointer and the real mouse taking it back.
  • game.rs, game/narrator.rs: the keyboard's own pointer events don't reach the narrator; the focused widget is the narration's focus. title.rs: the world list.
  • docs/controllers.md: the keyboard navigation.

How it was tested

  • cargo test -p horizon-client --bins key_focus (vanilla's key mapping, tab order and wrapping, a list as one stop, sliders' canChangeValue, text fields keeping their keys, arrows from no focus).
  • clippy (all targets) clean at this tip; fmt.

Known differences from vanilla

  • Tab follows reading order rather than vanilla's add order.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5348 **Author:** [@leifiyoo](https://github.com/leifiyoo) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `narrator/15-keyboard-focus` --- ### 📝 Commits (10+) - [`37313e8`](https://github.com/horizon-rust/horizon/commit/37313e8314057954e02ac247e317902a5d45d2b0) Narrate World Options' switches and lock, and the stats lists - [`6fd6a9b`](https://github.com/horizon-rust/horizon/commit/6fd6a9badb20ee9d0257b4330bcbe868b66d1cb4) Narrate the recipe book as RecipeBookComponent does - [`8049680`](https://github.com/horizon-rust/horizon/commit/80496802e2c752692690d9aca99b5e8707868233) Leave inactive edit boxes out and keep the book button's focus - [`a60214a`](https://github.com/horizon-rust/horizon/commit/a60214a2583f99ce3143b3f49ba24907ec133f31) Document the narrator - [`741cc76`](https://github.com/horizon-rust/horizon/commit/741cc760705bd9e12174f9b1d04f6d9e0b252d1c) Narrate options lists, key binds, pack lists and dialogs as vanilla does - [`bbbdd3d`](https://github.com/horizon-rust/horizon/commit/bbbdd3d1630bfd7d8fbc6d9d3a4859c4f8d7ecdc) Narrate game rules and command block switches as CycleButtons - [`9171f3b`](https://github.com/horizon-rust/horizon/commit/9171f3b8cf48554db014856481e0bd4175ab3dfa) Let horizon-ctl's keys and typing reach the screen narration - [`27f9488`](https://github.com/horizon-rust/horizon/commit/27f94881356c50d31f135a96b4035b59ed03f56e) Navigate menus with Tab, the arrows and Enter as vanilla does - [`bc79141`](https://github.com/horizon-rust/horizon/commit/bc791418cab7bf34ea09cc8076dbe64a3b5d71df) List two more narrator differences found end to end - [`3c46c26`](https://github.com/horizon-rust/horizon/commit/3c46c26016fcf51564cbf632ee242009e90c0a33) Document keyboard focus navigation ### 📊 Changes **22 files changed** (+2526 additions, -224 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/options_ui.rs` (+334 -85) 📝 `crates/horizon-client-render/src/pack_screen.rs` (+47 -6) 📝 `crates/horizon-client-render/src/ui.rs` (+21 -3) 📝 `crates/horizon-client-render/src/widgets.rs` (+102 -9) 📝 `crates/horizon-client/src/game.rs` (+22 -3) 📝 `crates/horizon-client/src/game/command_blocks.rs` (+126 -1) 📝 `crates/horizon-client/src/game/control.rs` (+4 -0) 📝 `crates/horizon-client/src/game/dialogs.rs` (+71 -0) ➕ `crates/horizon-client/src/game/key_focus.rs` (+473 -0) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+195 -1) 📝 `crates/horizon-client/src/game/narrator.rs` (+20 -12) 📝 `crates/horizon-client/src/game/pad.rs` (+2 -0) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+427 -61) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+98 -3) 📝 `crates/horizon-client/src/game/stats_screen.rs` (+104 -31) 📝 `crates/horizon-client/src/game_rules_screen.rs` (+100 -1) 📝 `crates/horizon-client/src/recipe_book_screen.rs` (+1 -1) 📝 `crates/horizon-client/src/screen_narrator.rs` (+124 -7) 📝 `crates/horizon-client/src/title.rs` (+45 -0) 📝 `docs/README.md` (+1 -0) _...and 2 more files_ </details> ### 📄 Description > 🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo. **Part 15 of 16 of the narrator series.** All 16 PRs have to be merged, in this order, for the narrator to work completely: #5333 → #5334 → #5335 → #5336 → #5337 → #5338 → #5339 → #5340 → #5341 → #5342 → #5343 → #5344 → #5346 → #5347 → #5348 → #5349. Each PR builds on the one before it (stacked branches), so until the previous one is merged this PR's diff also shows its commits; merging only some of them, or out of order, leaves the narrator unfinished. Stacked on #5347 — merge that first; until then this PR also shows its commits. Menus can now be used with the keyboard as in vanilla: Tab / Shift+Tab move the focus, the arrows move it by direction, Enter / Space / keypad Enter press the focused widget. The narrator reads the focused widget, which makes the menus usable without a mouse. ## What vanilla does `Screen.keyPressed`: Tab → `FocusNavigationEvent.TabNavigation`, arrows → `ArrowNavigation` (`ScreenRectangle`-based `nextFocusPathInDirection`), Enter/Space activate the focused widget; sliders follow `canChangeValue`, `EditBox` keeps its caret keys, a list is one Tab stop; the world list selects its focused row. ## What changed - `crates/horizon-client/src/game/key_focus.rs` (new): Tab order, the ported directional step, which keys a focused widget keeps. - `crates/horizon-client/src/game/pad_menu.rs`, `pad.rs`: the controller's focus targets shared with the keyboard; the keyboard's hidden pointer and the real mouse taking it back. - `game.rs`, `game/narrator.rs`: the keyboard's own pointer events don't reach the narrator; the focused widget is the narration's focus. `title.rs`: the world list. - `docs/controllers.md`: the keyboard navigation. ## How it was tested - `cargo test -p horizon-client --bins key_focus` (vanilla's key mapping, tab order and wrapping, a list as one stop, sliders' `canChangeValue`, text fields keeping their keys, arrows from no focus). - clippy (all targets) clean at this tip; fmt. ## Known differences from vanilla - Tab follows reading order rather than vanilla's add order. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:16:07 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6230
No description provided.