Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: js on Mon 16/01/2023 11:00:05

Title: [SOLVED] MouseButton enum
Post by: js on Mon 16/01/2023 11:00:05
Hello,

In the callback  on_mouse_click(MouseButton button)

I try to detect which button has been pressed:

switch(button) {
  case eMouseLeft:
    Display("left button");
    break;
  default:
    Display("unknown button: %d", button);
    break;

The problem is when i press left button, it's not seen as a eMouseLeft code.

The enum is described like this in the documentation:

enum MouseButton {
  eMouseLeft,
  eMouseRight,
  eMouseMiddle,
  eMouseLeftInv,
  eMouseMiddleInv,
  eMouseRightInv,
  eMouseWheelNorth,
  eMouseWheelSouth
};

So eMouseLeft must be 0 or 1 i think (depending the start index).

When i press the buttons of my mouse, it triggers the default branch in my switch/case.

I get those values from my display box:
left : 5
right : 6
middle : 7
wheel up : 8
wheel down : 9 (note the value greater than the number of values in the enum)

Well... i don't understand what happens.

Thank you.
Title: Re: MouseButton enum
Post by: Khris on Mon 16/01/2023 11:51:35
Your code works as expected for me. The value being 5 confirms my initial suspicion, you're left-clicking an inventory item, right? This is reflected by eMouseLeftInv.

(Only if custom inv click handling is activated in General Settings)
Title: Re: MouseButton enum
Post by: js on Mon 16/01/2023 12:53:49
Yes you're right. My tests are done on inventory item.

Thank you for your answer !