Skip to content

Fix: Dropping items outside of inventory menus#1159

Open
Adem-Kurt wants to merge 2 commits intosmartcmd:mainfrom
Adem-Kurt:patch-1
Open

Fix: Dropping items outside of inventory menus#1159
Adem-Kurt wants to merge 2 commits intosmartcmd:mainfrom
Adem-Kurt:patch-1

Conversation

@Adem-Kurt
Copy link
Contributor

Description

This PR fixes two separate bugs that prevented players from dropping items with clicking outside the inventory in menus.

Changes

Previous Behavior

  • In the Creative inventory, right-clicking outside the menu bounds while holding a stack of items did not drop a single item. Instead, the right-click input was intercepted to clear the hotbar.
  • In standard container menus (Survival Inventory, Chests, Furnaces, etc.), clicking outside the menu bounds with an item held did nothing. The item would remain attached to the cursor.

Root Cause

  1. Creative Menu: In IUIScene_CreativeMenu.cpp, handleValidKeyPress had a check that captured any right-click (buttonNum == 1) and triggered the hotbar clearing function, terminating the input flow before the outside drop logic could process it.
  2. Standard Menus: In AbstractContainerMenu.cpp, the clicked function had an early bounds check (if (slotIndex < 0 || slotIndex >= slots.size()) return nullptr;). Because clicking outside the UI sends a slot ID of SLOT_CLICKED_OUTSIDE (-999), this early check blocked the input, never allowing the drop code to execute.

New Behavior

  • Players can now drag items outside the Creative inventory and right-click to drop exactly one item per click without unexpectedly clearing their hotbar.
  • Players can now drag items outside standard containers (chests, crafting tables, standard inventory) and drop items (full stacks or single items) properly onto the ground.

Fix Implementation

  • Commit 1: Added !m_bPointerOutsideMenu to the right-click interception logic in IUIScene_CreativeMenu.cpp so it only clears the hotbar if the pointer is actually inside the UI boundaries.
  • Commit 2: Added an exception for SLOT_CLICKED_OUTSIDE in the initial boundary bounds check in AbstractContainerMenu::clicked so the -999 ID can properly reach the subsequent drag-and-drop code blocks.

AI Use Disclosure

I used AI as a search tool, find the code causing this bug.

Related Issues

@Adem-Kurt
Copy link
Contributor Author

2026-03-11.22-29-27.mp4

@jvnpr
Copy link

jvnpr commented Mar 12, 2026

Tested your branch, looks like there's a problem in the creative menu where some items don't get dropped even when the count reduces, leading to some getting lost. Doesn't look to be an issue in the inventory.

adem-kurt-1159-pull.mp4

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