[PR #358] [MERGED] Shift-click on every container screen, even when Shift is pressed after it opens #2519

Closed
opened 2026-11-02 15:56:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/inventory-shift


📝 Commits (1)

  • 293c589 Read the physical Shift and Ctrl keys on every container screen

📊 Changes

5 files changed (+24 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+7 -1)
📝 crates/horizon-client/src/game/control.rs (+12 -2)
📝 crates/horizon-client/src/game/mount_menu.rs (+1 -2)
📝 crates/horizon-client/src/game/recipe_book.rs (+3 -4)
📝 crates/horizon-client/src/game/stations.rs (+1 -2)

📄 Description

Shift-click now works on every container screen, including when Shift is pressed after the screen opens. Reported on Discord ("the shift button doesn't work in the inventory"), logged on #275.

What was wrong

#77/#87 made AbstractContainerScreen-style screens read the physical Shift keys (has_shift_down). The workstation screens, the horse/llama/camel inventory and the creative item grid still read Shift from the sneak mapping (keys):

  • stations.rs: anvil, grindstone, stonecutter, smithing table, enchanting table, cartography table, loom, beacon, villager trading, brewing stand
  • mount_menu.rs: horse, donkey, mule, llama, camel inventories
  • game.rs: the creative item grid

Behind an open screen a Shift press never reaches the mapping (KeyboardHandler.keyPress: only releases do, so sync_toggle leaves it up), and Right Shift isn't mapped at all. So shift-click there worked only if Shift was already held when the screen opened. These now read has_shift_down (InputWithModifiers.hasShiftDown). The recipe book read Ctrl the same way; it now reads the physical Control keys (Minecraft.hasControlDown).

horizon-ctl status now reports physical_keys (what the OS delivered) next to keys (the mapped set), so a script can see which one a screen gets.

macOS

winit 0.30.13 synthesises KeyboardInput for modifier keys from flagsChanged (platform_impl/macos/view.rs: update_modifiers), so physical_keys gets ShiftLeft/ShiftRight on macOS. I checked this on the Mac mini with real HID key events: a CGEvent flagsChanged for virtual key 56/60, posted at the HID tap to the frontmost game window. AppleScript's key down shift does not produce flagsChanged, so it can't stand in for a real key.

How tested

In game on the Mac mini (debug build, Metal), real Left Shift held, then horizon-ctl click-slot 0 with no scripted modifier:

screen (item) physical_keys result
anvil, before the fix (main, click-slot 0 shift) — sword picked up ❌
anvil (iron sword) ShiftLeft → input slot 600 ✅
grindstone (iron sword) ShiftLeft → 600 ✅
stonecutter (stone) ShiftLeft → 600 ✅
smithing table (netherite upgrade) ShiftLeft → 600 ✅
enchanting table (lapis) ShiftLeft → 601 ✅
cartography table (map) ShiftLeft → 601 ✅
loom (white banner) ShiftLeft → 600 ✅
brewing stand (nether wart) ShiftLeft → ingredient 303 ✅
beacon (3 iron ingots) ShiftLeft 1 → payment 600 (see below)
villager trading (emerald) ShiftLeft hotbar → main inventory ✅ (MerchantMenu never fills payment slots)
horse (saddle) ShiftLeft → saddle slot 700 ✅
chest, furnace, crafting table, hopper, blast furnace ShiftLeft quick-moved ✅ (already worked)
chest, Right Shift held before opening ShiftRight → 300 ✅

Found while testing, not changed here: the station screens' own quick-move rules are hand-written (stations.rs: quick_move) and the beacon differs from BeaconMenu.quickMoveStack, which only moves a stack of exactly 1 into the payment slot (a stack of 3 in the hotbar goes to the main inventory). I'll audit those against each vanilla quickMoveStack in a follow-up PR.

Self-check:

cargo fmt --all --check                                   ok
cargo clippy --workspace --all-targets -- -D warnings     ok
cargo test -p horizon-client                              ok (666 + 41 + 15 + ... passed)
tools/parity.py --changed origin/main                     16 harnesses: 16 passed, 0 failed (39.6 min)

Part of #275 (Shift report). Next PRs in this stack: creative item tabs as vanilla, Shift + double-click, the quick craft drag highlight.

🤖 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/358 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/inventory-shift` --- ### 📝 Commits (1) - [`293c589`](https://github.com/horizon-rust/horizon/commit/293c589e35b5af7389c2110a2c6b3db5a92ece8a) Read the physical Shift and Ctrl keys on every container screen ### 📊 Changes **5 files changed** (+24 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+7 -1) 📝 `crates/horizon-client/src/game/control.rs` (+12 -2) 📝 `crates/horizon-client/src/game/mount_menu.rs` (+1 -2) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+3 -4) 📝 `crates/horizon-client/src/game/stations.rs` (+1 -2) </details> ### 📄 Description Shift-click now works on every container screen, including when Shift is pressed after the screen opens. Reported on Discord ("the shift button doesn't work in the inventory"), logged on #275. ## What was wrong #77/#87 made `AbstractContainerScreen`-style screens read the physical Shift keys (`has_shift_down`). The workstation screens, the horse/llama/camel inventory and the creative item grid still read Shift from the **sneak mapping** (`keys`): - `stations.rs`: anvil, grindstone, stonecutter, smithing table, enchanting table, cartography table, loom, beacon, **villager trading**, brewing stand - `mount_menu.rs`: horse, donkey, mule, llama, camel inventories - `game.rs`: the creative item grid Behind an open screen a Shift *press* never reaches the mapping (`KeyboardHandler.keyPress`: only releases do, so `sync_toggle` leaves it up), and Right Shift isn't mapped at all. So shift-click there worked only if Shift was already held when the screen opened. These now read `has_shift_down` (`InputWithModifiers.hasShiftDown`). The recipe book read Ctrl the same way; it now reads the physical Control keys (`Minecraft.hasControlDown`). `horizon-ctl status` now reports `physical_keys` (what the OS delivered) next to `keys` (the mapped set), so a script can see which one a screen gets. ## macOS winit 0.30.13 synthesises `KeyboardInput` for modifier keys from `flagsChanged` (`platform_impl/macos/view.rs: update_modifiers`), so `physical_keys` gets `ShiftLeft`/`ShiftRight` on macOS. I checked this on the Mac mini with **real HID key events**: a `CGEvent` `flagsChanged` for virtual key 56/60, posted at the HID tap to the frontmost game window. AppleScript's `key down shift` does *not* produce `flagsChanged`, so it can't stand in for a real key. ## How tested In game on the Mac mini (debug build, Metal), real Left Shift held, then `horizon-ctl click-slot 0` with **no** scripted modifier: | screen (item) | `physical_keys` | result | |---|---|---| | anvil, before the fix (main, `click-slot 0 shift`) | — | sword picked up ❌ | | anvil (iron sword) | `ShiftLeft` | → input slot 600 ✅ | | grindstone (iron sword) | `ShiftLeft` | → 600 ✅ | | stonecutter (stone) | `ShiftLeft` | → 600 ✅ | | smithing table (netherite upgrade) | `ShiftLeft` | → 600 ✅ | | enchanting table (lapis) | `ShiftLeft` | → 601 ✅ | | cartography table (map) | `ShiftLeft` | → 601 ✅ | | loom (white banner) | `ShiftLeft` | → 600 ✅ | | brewing stand (nether wart) | `ShiftLeft` | → ingredient 303 ✅ | | beacon (3 iron ingots) | `ShiftLeft` | 1 → payment 600 (see below) | | villager trading (emerald) | `ShiftLeft` | hotbar → main inventory ✅ (MerchantMenu never fills payment slots) | | horse (saddle) | `ShiftLeft` | → saddle slot 700 ✅ | | chest, furnace, crafting table, hopper, blast furnace | `ShiftLeft` | quick-moved ✅ (already worked) | | chest, **Right Shift held before opening** | `ShiftRight` | → 300 ✅ | Found while testing, not changed here: the station screens' own quick-move rules are hand-written (`stations.rs: quick_move`) and the beacon differs from `BeaconMenu.quickMoveStack`, which only moves a stack of exactly 1 into the payment slot (a stack of 3 in the hotbar goes to the main inventory). I'll audit those against each vanilla `quickMoveStack` in a follow-up PR. Self-check: ``` cargo fmt --all --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client ok (666 + 41 + 15 + ... passed) tools/parity.py --changed origin/main 16 harnesses: 16 passed, 0 failed (39.6 min) ``` Part of #275 (Shift report). Next PRs in this stack: creative item tabs as vanilla, Shift + double-click, the quick craft drag highlight. 🤖 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-02 15:56:52 +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#2519
No description provided.