I have a custom inventory. I wanted to create custom on_mouse_click interactions with it, instead of using the system which comes with AGS.
If I set, in general settings, the "Override built-in inventory window click handling" to false, the GUI detects clicks on the inventory item correctly and I can select an item as active inventory item with the interact mouse cursor.
I wanted to alter this functionality in some ways, and set the above mentioned setting to true, which causes the game to call "on_mouse_click" even inside inventory windows as usual.
To test the issue I'm about to describe, I've simplified the code as below.
Code: ags
The Display commands I've set up reveal that on_mouse_click command is correctly called (game displays ("click"), but then it gets weird: the check for which mouse button was clicked fails to detect which button was clicked. The same check works outside of the inventory GUI, but inside the inventory GUI it seems that the if -lines are never run at all and if I click on an inventory item, the script above displays "fail" on screen, denoting that the script did not detect left-click or right-click, but instead went for the "else" option.
What causes this behavior inside an inventory GUI?
If I set, in general settings, the "Override built-in inventory window click handling" to false, the GUI detects clicks on the inventory item correctly and I can select an item as active inventory item with the interact mouse cursor.
I wanted to alter this functionality in some ways, and set the above mentioned setting to true, which causes the game to call "on_mouse_click" even inside inventory windows as usual.
To test the issue I'm about to describe, I've simplified the code as below.
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
Display("click");
if (button == eMouseLeft) {
Display("left");
} else if (button == eMouseRight) {
Display("right");
} else {
Display("fail");
}
ProcessClick(mouse.x, mouse.y, eModeInteract);
}
The Display commands I've set up reveal that on_mouse_click command is correctly called (game displays ("click"), but then it gets weird: the check for which mouse button was clicked fails to detect which button was clicked. The same check works outside of the inventory GUI, but inside the inventory GUI it seems that the if -lines are never run at all and if I click on an inventory item, the script above displays "fail" on screen, denoting that the script did not detect left-click or right-click, but instead went for the "else" option.
What causes this behavior inside an inventory GUI?