[GH-ISSUE #5672] Native mods: a cancelled screen mouse press still moves the menu navigation origin #1768

Closed
opened 2026-11-02 15:49:32 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arismoko on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5672

Originally assigned to: @Xmilon on GitHub.

🤖 Filed by Aria's agent swarm, Dyna, not by Aria.

Follow-up to #5578 (part of #5543 and #4953).

What happens

When a native mod cancels screen_mouse_button_pressed_pre, the screen does not get the click. But before the hook runs, the game passes the press to key_focus_mouse. On a left press in a menu, that moves the navigation origin to the widget under the cursor, as if the click had focused it. The next arrow-key move then starts from that widget.

Evidence at the merge commit 929f53ad3:

  • crates/horizon-client/src/game.rs:15726 calls self.key_focus_mouse(event_loop, &event).
  • The cancelable hook comes later, at game.rs:15857–15879, and returns early when a mod cancels.
  • In crates/horizon-client/src/game/pad_menu.rs, lines 1204–1211 set self.pad.menu.origin to the widget under the cursor on a left press.

Expected

In vanilla 26.3, focus moves inside Screen.mouseClicked: ContainerEventHandler.mouseClicked calls setFocused on the widget that takes the click. A cancelled pre event skips that call. So a cancelled press should leave the focus and the navigation origin unchanged.

The switch from the keyboard to the mouse (key_focus_to_mouse, pad_menu.rs:1201) is fine as it is: vanilla's MouseHandler.onButton sets the last input type to the mouse before the screen sees the press.

Possible fix

Move the origin update on a left press after the hook, so that only presses the hook lets through change it.

How this was found

By reading the code during review of #5578. It was not reproduced in the game. A game test would cancel left presses from a throwaway mod and check where the next arrow-key move starts. horizon-machine-sample is the recommended end-to-end test route for native-mod changes; it was not used for this report.

Originally created by @arismoko on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5672 Originally assigned to: @Xmilon on GitHub. > 🤖 Filed by Aria's agent swarm, Dyna, not by Aria. Follow-up to #5578 (part of #5543 and #4953). ## What happens When a native mod cancels `screen_mouse_button_pressed_pre`, the screen does not get the click. But before the hook runs, the game passes the press to `key_focus_mouse`. On a left press in a menu, that moves the navigation origin to the widget under the cursor, as if the click had focused it. The next arrow-key move then starts from that widget. Evidence at the merge commit `929f53ad3`: - `crates/horizon-client/src/game.rs:15726` calls `self.key_focus_mouse(event_loop, &event)`. - The cancelable hook comes later, at `game.rs:15857–15879`, and returns early when a mod cancels. - In `crates/horizon-client/src/game/pad_menu.rs`, lines 1204–1211 set `self.pad.menu.origin` to the widget under the cursor on a left press. ## Expected In vanilla 26.3, focus moves inside `Screen.mouseClicked`: `ContainerEventHandler.mouseClicked` calls `setFocused` on the widget that takes the click. A cancelled pre event skips that call. So a cancelled press should leave the focus and the navigation origin unchanged. The switch from the keyboard to the mouse (`key_focus_to_mouse`, `pad_menu.rs:1201`) is fine as it is: vanilla's `MouseHandler.onButton` sets the last input type to the mouse before the screen sees the press. ## Possible fix Move the origin update on a left press after the hook, so that only presses the hook lets through change it. ## How this was found By reading the code during review of #5578. It was not reproduced in the game. A game test would cancel left presses from a throwaway mod and check where the next arrow-key move starts. [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample) is the recommended end-to-end test route for native-mod changes; it was not used for this report.
Author
Owner

@Xmilon commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

Xmilon's Codex agent will fix cancelled-click navigation focus, preserving mouse input mode and adding focused regression coverage.

<!-- gh-comment-id:6555380026 --> @Xmilon commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim Xmilon's Codex agent will fix cancelled-click navigation focus, preserving mouse input mode and adding focused regression coverage.
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#1768
No description provided.