Skip to content

Fix initial cursor position for in-game UI elements#1120

Merged
sylvessa merged 1 commit intoMCLCE:mainfrom
ayushthoren:cursor-position-fix
Mar 24, 2026
Merged

Fix initial cursor position for in-game UI elements#1120
sylvessa merged 1 commit intoMCLCE:mainfrom
ayushthoren:cursor-position-fix

Conversation

@ayushthoren
Copy link
Copy Markdown
Contributor

Description

Fixes cursor behavior in UI containers such that the position is now deterministic depending on the type of input being used (controller vs KBM).

The cursor now defaults to the first hotbar slot on controller, and defaults to the center of the UI container on KBM.

Changes

Previous Behavior

Cursor position persisted across menu closes/reopens.

Root Cause

Cursor state was being saved (to g_savedInventoryCursorPos.x and g_savedInventoryCursorPos.y) when containers were closed and restored, using those cached values on next open.

New Behavior

Cursor position no longer persists between menu sessions.

  • Controller inputs open with the cursor at the first hotbar slot.
  • KBM inputs open with the cursor at the center of the menu panel (not forced to a slot).

Fix Implementation

Removed cursor persistence logic:

  • Deleted SavedInventoryCursorPos declaration/usage.
  • Removed save and restore logic.

Updated UIScene_AbstractContainerMenu::PlatformInitialize():

  • Kept existing default pointer to first hotbar slot.
  • Added Windows64 check: if iPad == 0 && g_KBMInput.IsKBMActive(), place pointer at panel center.
    • Checking if iPad ==0 ensures that KBM inputs only affect the primary player's experience on splitscreen, since additional players are guaranteed to be using controllers.

AI Use Disclosure

No AI was used to implement these changes.

Related Issues

  • Fixes Discord Thread 1480743335579877517

Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
@codeHusky codeHusky self-requested a review March 24, 2026 00:26
@sylvessa sylvessa merged commit ed9cbae into MCLCE:main Mar 24, 2026
1 check passed
@ayushthoren ayushthoren deleted the cursor-position-fix branch March 24, 2026 03:31
chrisGrando pushed a commit to chrisGrando/LegacyMinecraft that referenced this pull request Mar 26, 2026
Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
ArchieDxncan pushed a commit to ArchieDxncan/LegacyDxncan that referenced this pull request Apr 1, 2026
Signed-off-by: Ayush Thoren <ayushthoren@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants