@@ -79,12 +79,26 @@ bool CharacterEquipmentPanel::init()
79
79
this ->inventoryListBox .setOverrideColor (i, equipColor);
80
80
});
81
81
82
- this ->addButtonProxy (MouseButtonType::Left, this ->inventoryListBox .getItemGlobalRect (i),
83
- [this , i]()
82
+ ButtonProxy::RectFunction itemRectFunc = [this , i]()
84
83
{
85
- const int firstVisibleIndex = this ->inventoryListBox .getFirstVisibleItemIndex ();
86
- this ->inventoryListBox .getCallback (firstVisibleIndex + i)();
87
- });
84
+ return this ->inventoryListBox .getItemGlobalRect (i);
85
+ };
86
+
87
+ ButtonProxy::Callback itemCallback = this ->inventoryListBox .getCallback (i);
88
+
89
+ ButtonProxy::ActiveFunction itemActiveFunction = [this , &game]()
90
+ {
91
+ // @todo: I don't like every button proxy having to handle mouse position, fix this design.
92
+ // - maybe should give the button proxy a parent rect that all clicks have to be inside, then
93
+ // the active func becomes obsolete
94
+ const InputManager &inputManager = game.inputManager ;
95
+ const Int2 mousePosition = inputManager.getMousePosition ();
96
+ const Int2 mouseClassicPosition = game.renderer .nativeToOriginal (mousePosition);
97
+ const Rect inventoryListBoxRect = this ->inventoryListBox .getRect ();
98
+ return inventoryListBoxRect.contains (mouseClassicPosition);
99
+ };
100
+
101
+ this ->addButtonProxy (MouseButtonType::Left, itemRectFunc, itemCallback, itemActiveFunction);
88
102
}
89
103
90
104
this ->backToStatsButton = Button<Game&>(
0 commit comments