fix(ui): select retained items on mouse down

Port UIElement_ListBox's press-time selection ordering through the shared retained item-list contract. Inventory, loot, paperdoll, and physical shortcuts now update canonical selection before release or drag promotion, while target-mode consumption suppresses drag and release-time activation.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-24 06:17:31 +02:00
parent 2dd5cb80d2
commit 043ab10b3c
18 changed files with 292 additions and 62 deletions

View file

@ -460,7 +460,7 @@ public class InventoryControllerTests
}
[Fact]
public void ClickGridItem_movesSquareOnly_noWire_keepsOpenContainer()
public void MouseDownGridItem_movesSquareImmediately_noWire_keepsOpenContainer()
{
var (layout, grid, _, top, _, _, _, _) = BuildLayout();
var objects = new ClientObjectTable();
@ -468,7 +468,8 @@ public class InventoryControllerTests
var uses = new List<uint>();
Bind(layout, objects, uses: uses);
grid.GetItem(0)!.Clicked!(); // select the loose item
UiItemSlot item = grid.GetItem(0)!;
item.OnEvent(new UiEvent(0u, item, UiEventType.MouseDown));
Assert.True(grid.GetItem(0)!.Selected); // square on the selected grid item
Assert.True(top.GetItem(0)!.IsOpenContainer); // main pack still the open container (unchanged)
@ -476,7 +477,7 @@ public class InventoryControllerTests
}
[Fact]
public void ClickGridItem_updatesSharedSelection_andExternalSelectionMovesSquare()
public void MouseDownGridItem_updatesSharedSelection_andExternalSelectionMovesSquare()
{
var (layout, grid, _, _, _, _, _, _) = BuildLayout();
var objects = new ClientObjectTable();
@ -485,7 +486,8 @@ public class InventoryControllerTests
var selection = new SelectionState();
Bind(layout, objects, selection: selection);
grid.GetItem(0)!.Clicked!();
UiItemSlot item = grid.GetItem(0)!;
item.OnEvent(new UiEvent(0u, item, UiEventType.MouseDown));
Assert.Equal(0xAu, selection.SelectedObjectId);
Assert.True(grid.GetItem(0)!.Selected);
@ -555,7 +557,8 @@ public class InventoryControllerTests
selection: new SelectionState(),
datFont: null,
itemInteraction: interaction);
grid.GetItem(0)!.Clicked!();
UiItemSlot item = grid.GetItem(0)!;
item.OnEvent(new UiEvent(0u, item, UiEventType.MouseDown));
Assert.True(grid.GetItem(0)!.Selected);
Assert.True(interaction.ActivateItem(0xAu));