[PR #5578] [MERGED] Native mods: mouse button press and release on the open screen (API next) #6365

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5578
Author: @Sylviromi
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: screen-mouse-button


📝 Commits (10+)

  • e39e008 Native mods: mouse button press and release on the open screen
  • 5f87b9e Native mods: mouse hook docs, which screens fire
  • 7c42d32 Native mods: the screen-hook gate is a helper, not a hook point
  • 4685ab0 Native mods: fragment names the renamed gate
  • 068b434 Merge branch 'screen-render-post' into screen-mouse-button
  • 8d98852 Screen mouse hooks: buttons past 4 are the platform's numbers
  • 7376337 Merge #5571's main merge into #5578
  • 22a3c3c Merge branch 'n5571' into n5578
  • ddeecba Merge remote-tracking branch 'origin/main' into n5578
  • 9be37e6 Merge remote-tracking branch 'origin/main' into n5578

📊 Changes

4 files changed (+221 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+124 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+80 -3)
📝 crates/horizon-client/src/game/pad_menu.rs (+8 -0)
➕ tools/native-hook-fragments/screen_mouse_button.json (+9 -0)

📄 Description

🤖 Opened by Sylviromi's AI agent (Claude Code, claude-sonnet-5-5), not by Sylviromi personally.

Part of #5543 (2 of 4: mouse buttons). Stacked on #5571: the first commits here are #5571's; review from e39e0088c on, or after #5571 merges this diff shrinks to ~220 lines.

What and why

Adds native_screen_mouse_button_pressed_pre and native_screen_mouse_button_released_pre (NeoForge ScreenEvent.MouseButtonPressed.Pre / MouseButtonReleased.Pre), so a native mod can take a click on an open screen before the game does. Signature: (&self, screen: &NativeScreenView, button: i32, modifiers: u32, canceled: &mut bool). Hook API: next.

  • Buttons are GLFW numbers (0 left, 1 right, 2 middle, 3 back, 4 forward) and modifiers are GLFW bits (shift 1, ctrl 2, alt 4, super 8), so no windowing types enter the API. The pointer is in screen.mouse.
  • Fired first in the window-event handler for mouse buttons while a game screen is open (also Options and the pack list opened from the title screen), before the container hotkey, sort, header, slot and drag handling. A cancelled press goes no further.
  • Cancel a release only together with its press: a release the screen took ends its drag, as in vanilla.
  • Never fires: the title screen itself, connect/loading screens, prompts/books/sign editors over gameplay, while a world loads or saves, gamepad or keyboard-focus clicks (a guard skips synthetic pad input).
  • Helpers shared by the input hooks: screen_view_now() and screen_hooks_open().
  • Pending fragment: tools/native-hook-fragments/screen_mouse_button.json. Unit tests cover the GLFW button/modifier mapping.

In-game proof

A test native mod cancelled presses inside a box over a chest's first slot. With 5 diamonds in slot 0 and 5 emeralds in slot 1, a click on slot 0 left the diamonds in place (data get block afterwards: still in slot 0), while clicks on slot 1 and then on an empty inventory slot moved the emeralds into the player's inventory. The mod logged one cancelled press/release pair, then the pairs it let through. The script computed PASS. No screenshot: the hook has no visuals of its own.

Kind

  • feature: something new for players (listed under New in the release notes)

Label: feature

Vanilla reference

NeoForge ScreenEvent.MouseButtonPressed.Pre / MouseButtonReleased.Pre, fired from MouseHandler.onPress before Screen.mouseClicked / mouseReleased (vanilla Screen.mouseClicked / mouseReleased are the calls it precedes). There is no parity harness for this ticket (it adds a hook, no vanilla behaviour changes).

Other projects' code

none

Self-check

Note: the scope counts #5571's commits too (this branch is stacked on it).

pr_ready (tools/pr_ready.py --quick on boilingpoint, against origin/main at d55bb43ab, 1 min 33 s)

Check Result
Scope ✅ 7 files, +498 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (42 s)
rustfmt ✅ (10 s)
clippy ✅ (20 s)
tests: horizon-client ✅ 1579 passed (20 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

"Allow edits by maintainers" is on (default for fork PRs).

🤖 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/5578 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `screen-mouse-button` --- ### 📝 Commits (10+) - [`e39e008`](https://github.com/horizon-rust/horizon/commit/e39e0088cbf9a844d77ea2a4857ad1ef8ff8ec57) Native mods: mouse button press and release on the open screen - [`5f87b9e`](https://github.com/horizon-rust/horizon/commit/5f87b9e60df2958a85ac66ec31bbb74c727add74) Native mods: mouse hook docs, which screens fire - [`7c42d32`](https://github.com/horizon-rust/horizon/commit/7c42d3272397bb234024efa4e0f94bf6eca98688) Native mods: the screen-hook gate is a helper, not a hook point - [`4685ab0`](https://github.com/horizon-rust/horizon/commit/4685ab06e272d177132ce586b34e141b74fa0715) Native mods: fragment names the renamed gate - [`068b434`](https://github.com/horizon-rust/horizon/commit/068b434a3d00fd23689d2276cf9c109e67df2890) Merge branch 'screen-render-post' into screen-mouse-button - [`8d98852`](https://github.com/horizon-rust/horizon/commit/8d98852911da1d018defe3e6216c1c4f595d88db) Screen mouse hooks: buttons past 4 are the platform's numbers - [`7376337`](https://github.com/horizon-rust/horizon/commit/737633786c864e5b7e76da37d2ffb85fb56b243d) Merge #5571's main merge into #5578 - [`22a3c3c`](https://github.com/horizon-rust/horizon/commit/22a3c3c55b1ca4e16fb376ef3f80bb63d3a5f67c) Merge branch 'n5571' into n5578 - [`ddeecba`](https://github.com/horizon-rust/horizon/commit/ddeecbad3b94f89f94682461261ad6571173c6f6) Merge remote-tracking branch 'origin/main' into n5578 - [`9be37e6`](https://github.com/horizon-rust/horizon/commit/9be37e6877194541f5f8b387de5ee97018b898a7) Merge remote-tracking branch 'origin/main' into n5578 ### 📊 Changes **4 files changed** (+221 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+124 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+80 -3) 📝 `crates/horizon-client/src/game/pad_menu.rs` (+8 -0) ➕ `tools/native-hook-fragments/screen_mouse_button.json` (+9 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, claude-sonnet-5-5), not by Sylviromi personally. Part of #5543 (2 of 4: mouse buttons). Stacked on #5571: the first commits here are #5571's; review from e39e0088c on, or after #5571 merges this diff shrinks to ~220 lines. ## What and why Adds `native_screen_mouse_button_pressed_pre` and `native_screen_mouse_button_released_pre` (NeoForge `ScreenEvent.MouseButtonPressed.Pre` / `MouseButtonReleased.Pre`), so a native mod can take a click on an open screen before the game does. Signature: `(&self, screen: &NativeScreenView, button: i32, modifiers: u32, canceled: &mut bool)`. Hook API: next. - Buttons are GLFW numbers (0 left, 1 right, 2 middle, 3 back, 4 forward) and modifiers are GLFW bits (shift 1, ctrl 2, alt 4, super 8), so no windowing types enter the API. The pointer is in `screen.mouse`. - Fired first in the window-event handler for mouse buttons while a game screen is open (also Options and the pack list opened from the title screen), before the container hotkey, sort, header, slot and drag handling. A cancelled press goes no further. - Cancel a release only together with its press: a release the screen took ends its drag, as in vanilla. - Never fires: the title screen itself, connect/loading screens, prompts/books/sign editors over gameplay, while a world loads or saves, gamepad or keyboard-focus clicks (a guard skips synthetic pad input). - Helpers shared by the input hooks: `screen_view_now()` and `screen_hooks_open()`. - Pending fragment: `tools/native-hook-fragments/screen_mouse_button.json`. Unit tests cover the GLFW button/modifier mapping. ## In-game proof A test native mod cancelled presses inside a box over a chest's first slot. With 5 diamonds in slot 0 and 5 emeralds in slot 1, a click on slot 0 left the diamonds in place (`data get block` afterwards: still in slot 0), while clicks on slot 1 and then on an empty inventory slot moved the emeralds into the player's inventory. The mod logged one cancelled press/release pair, then the pairs it let through. The script computed PASS. No screenshot: the hook has no visuals of its own. ## Kind - [x] feature: something new for players (listed under New in the release notes) Label: feature ## Vanilla reference NeoForge `ScreenEvent.MouseButtonPressed.Pre` / `MouseButtonReleased.Pre`, fired from `MouseHandler.onPress` before `Screen.mouseClicked` / `mouseReleased` (vanilla `Screen.mouseClicked` / `mouseReleased` are the calls it precedes). There is no parity harness for this ticket (it adds a hook, no vanilla behaviour changes). ## Other projects' code none ## Self-check Note: the scope counts #5571's commits too (this branch is stacked on it). **pr_ready** (`tools/pr_ready.py --quick` on boilingpoint, against origin/main at d55bb43ab, 1 min 33 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +498 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (42 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (20 s) | | tests: horizon-client | ✅ 1579 passed (20 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | "Allow edits by maintainers" is on (default for fork PRs). 🤖 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:19:14 +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#6365
No description provided.