[SOLVED] MouseButton enum

Started by js, Mon 16/01/2023 11:00:05

Previous topic - Next topic

js

Hello,

In the callback  on_mouse_click(MouseButton button)

I try to detect which button has been pressed:

Code: ags
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:

Code: ags
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.

Khris

#1
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)

js

Yes you're right. My tests are done on inventory item.

Thank you for your answer !


SMF spam blocked by CleanTalk