Skip to content

-[NSEvent buttonNumber] reports wrong values for mouse events on X11 backend #85

Description

@doganov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions