[PR #7120] [MERGED] Create World: Ctrl plus a digit or Tab picks a tab #7354

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7120
Author: @MSedgeMC
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/create-world-tab-keys


📝 Commits (1)

  • f3b2672 Create World: Ctrl plus a digit or Tab picks a tab

📊 Changes

5 files changed (+175 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+17 -0)
📝 crates/horizon-client/src/game/startup_menu.rs (+15 -0)
📝 crates/horizon-client/src/title.rs (+42 -8)
📝 crates/horizon-client/src/title/create_world.rs (+42 -0)
📝 crates/horizon-client/src/title/tests.rs (+59 -0)

📄 Description

Vanilla

CreateWorldScreen.keyPressed offers the key to its MenuTabBar (a
TabNavigationBar) before Screen.keyPressed and before the open tab's own
widgets, and TabNavigationBar.keyPressed takes the keys with Ctrl held
(hasControlDownWithQuirk):

  • a digit key is Math.floorMod(key.getNumericKeyValue() - 1, 10), so Ctrl+1
    is the first tab and Ctrl+0 the tenth, then Mth.clamp(index, 0, tabs.size() - 1)
    keeps the last tab for anything past it — Ctrl+4..9 and Ctrl+0 all land on
    the last tab;
  • KeyEvent.isCycleFocus() (Tab) steps one tab forward, or back with
    hasShiftDown, wrapping with floorMod;
  • the tab goes through TabManager.setCurrentTab, which plays
    SoundEvents.UI_BUTTON_CLICK only when the open tab actually changed, and
    the new tab's widgets replace the old tab's, so a field that had the keys
    loses them.

Horizon

title.rs switched Create World tabs only from a mouse press on the tab strip
(create_world::tab_at). Nothing routed keys to the tab bar: Ctrl+1..9 did
nothing at all, and Ctrl+Tab fell into the focus-walking arm (tab_dir), which
vanilla never sees on this screen. The tab-strip mouse path was also written
inline in click.

create_world::next_tab_index is TabNavigationBar.getNextTabIndex (digit
floorMod(key - 1, 10) from either number row, Tab ±1 with wrap),
Title::tab_bar_key is keyPressed plus the Mth.clamp, and both it and the
mouse path go through Title::select_create_tab (setCurrentTab: the tab, no
field focus, and the click sound when it changed). Game and the StartupMenu
that owns the title while resources load both call tab_bar_key before their
own key match, with the quirk modifier (InputQuirks.EDIT_SHORTCUT_KEY_MODIFIER:
Cmd on macOS, Ctrl elsewhere).

Proven: title::tests::ctrl_digits_and_ctrl_tab_switch_the_create_world_tabs
— Ctrl+2 and Ctrl+3 (number row and keypad) open the World and More tabs and
drop the name box's focus (focus 0 -> 2); Ctrl+3 again changes nothing and
plays no sound; Ctrl+4, Ctrl+9 and Ctrl+0 stay on the last tab; Ctrl+Tab and
Ctrl+Shift+Tab wrap in both directions; a digit without Ctrl returns None so
the field still gets it; a screen with no tab bar (the main menu) ignores all
of them. The existing
create_world_tabs_follow_vanilla_and_their_choices_reach_the_action still
passes over the shared mouse path. cargo test -p horizon-client-lib --lib title::
and clippy on horizon-client-lib/horizon-client are clean.

Not proven: no keystroke is driven through a real window here, so the two
call sites in Game/StartupMenu are compiled and reviewed but not exercised
end to end. The macOS Cmd form cannot run on this machine. Every Create World
tab is active, so the branch of getNextTabIndex that skips an inactive tab
has nothing to skip.


🔄 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/7120 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/create-world-tab-keys` --- ### 📝 Commits (1) - [`f3b2672`](https://github.com/horizon-rust/horizon/commit/f3b26725d640bdc3742131687c8cd033e8b67c77) Create World: Ctrl plus a digit or Tab picks a tab ### 📊 Changes **5 files changed** (+175 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+17 -0) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+15 -0) 📝 `crates/horizon-client/src/title.rs` (+42 -8) 📝 `crates/horizon-client/src/title/create_world.rs` (+42 -0) 📝 `crates/horizon-client/src/title/tests.rs` (+59 -0) </details> ### 📄 Description ## Vanilla `CreateWorldScreen.keyPressed` offers the key to its `MenuTabBar` (a `TabNavigationBar`) before `Screen.keyPressed` and before the open tab's own widgets, and `TabNavigationBar.keyPressed` takes the keys with Ctrl held (`hasControlDownWithQuirk`): * a digit key is `Math.floorMod(key.getNumericKeyValue() - 1, 10)`, so Ctrl+1 is the first tab and Ctrl+0 the tenth, then `Mth.clamp(index, 0, tabs.size() - 1)` keeps the last tab for anything past it — Ctrl+4..9 and Ctrl+0 all land on the last tab; * `KeyEvent.isCycleFocus()` (Tab) steps one tab forward, or back with `hasShiftDown`, wrapping with `floorMod`; * the tab goes through `TabManager.setCurrentTab`, which plays `SoundEvents.UI_BUTTON_CLICK` only when the open tab actually changed, and the new tab's widgets replace the old tab's, so a field that had the keys loses them. ## Horizon `title.rs` switched Create World tabs only from a mouse press on the tab strip (`create_world::tab_at`). Nothing routed keys to the tab bar: Ctrl+1..9 did nothing at all, and Ctrl+Tab fell into the focus-walking arm (`tab_dir`), which vanilla never sees on this screen. The tab-strip mouse path was also written inline in `click`. `create_world::next_tab_index` is `TabNavigationBar.getNextTabIndex` (digit `floorMod(key - 1, 10)` from either number row, Tab `±1` with wrap), `Title::tab_bar_key` is `keyPressed` plus the `Mth.clamp`, and both it and the mouse path go through `Title::select_create_tab` (`setCurrentTab`: the tab, no field focus, and the click sound when it changed). `Game` and the `StartupMenu` that owns the title while resources load both call `tab_bar_key` before their own key match, with the quirk modifier (`InputQuirks.EDIT_SHORTCUT_KEY_MODIFIER`: Cmd on macOS, Ctrl elsewhere). **Proven:** `title::tests::ctrl_digits_and_ctrl_tab_switch_the_create_world_tabs` — Ctrl+2 and Ctrl+3 (number row and keypad) open the World and More tabs and drop the name box's focus (`focus` 0 -> 2); Ctrl+3 again changes nothing and plays no sound; Ctrl+4, Ctrl+9 and Ctrl+0 stay on the last tab; Ctrl+Tab and Ctrl+Shift+Tab wrap in both directions; a digit without Ctrl returns `None` so the field still gets it; a screen with no tab bar (the main menu) ignores all of them. The existing `create_world_tabs_follow_vanilla_and_their_choices_reach_the_action` still passes over the shared mouse path. `cargo test -p horizon-client-lib --lib title::` and clippy on `horizon-client-lib`/`horizon-client` are clean. **Not proven:** no keystroke is driven through a real window here, so the two call sites in `Game`/`StartupMenu` are compiled and reviewed but not exercised end to end. The macOS Cmd form cannot run on this machine. Every Create World tab is active, so the branch of `getNextTabIndex` that skips an inactive tab has nothing to skip. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:38:12 +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#7354
No description provided.