The documentation for -[NSEvent buttonNumber] clearly states that the left mouse button's number is 0, the right mouse button is 1, and so on: https://www.gnustep.org/resources/documentation/Developer/Gui/Reference/NSEvent.html#method$NSEvent-buttonNumber
Unfortunately, at least on the X11 backend, the buttons are numbered starting from 1. This becomes evident in the relevant source code, -[XGServerWindow _setupMouse], where generic.lMouse is initialized with buttons[0], which is Button1, which is 1.
|
generic.lMouse = buttons[0]; |
Later, the value of generic.lMouse is used as is as a buttonNumber: argument when creating an NSEvent instance. This implementation leads to the left mouse button being reported by -[NSEvent buttonNumber] as 1, the right mouse button as 2, and so on.
I haven't tried the Wayland backend, but the comments in the relevant source file also doesn't inspire confidence that the documented semantics of buttonNumber is being followed.
The documentation for
-[NSEvent buttonNumber]clearly states that the left mouse button's number is 0, the right mouse button is 1, and so on: https://www.gnustep.org/resources/documentation/Developer/Gui/Reference/NSEvent.html#method$NSEvent-buttonNumberUnfortunately, at least on the X11 backend, the buttons are numbered starting from 1. This becomes evident in the relevant source code,
-[XGServerWindow _setupMouse], wheregeneric.lMouseis initialized withbuttons[0], which isButton1, which is 1.libs-back/Source/x11/XGServerWindow.m
Line 1332 in 3b74bff
Later, the value of
generic.lMouseis used as is as abuttonNumber:argument when creating an NSEvent instance. This implementation leads to the left mouse button being reported by-[NSEvent buttonNumber]as 1, the right mouse button as 2, and so on.I haven't tried the Wayland backend, but the comments in the relevant source file also doesn't inspire confidence that the documented semantics of
buttonNumberis being followed.