Skip to content

Existing CGMouseButton enum is too limited #745

@pentamassiv

Description

@pentamassiv

The existing CGMouseButton enum is too limited for what Quartz actually supports. Apple allows 0–31, but the Rust enum only exposes Left, Right, Center:

// Constants that specify buttons on a one, two, or three-button mouse.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CGMouseButton {
    Left,
    Right,
    Center,
}

This makes it impossible to simulate an event with the new_mouse_event function with the buttons 3-31.

I can create a PR to fix it, but I am not sure what solution you would prefer. Do you want to add enum variants Button3, Button4,...,Button31 or do you want to change it to be constants? I prefer adding enums to keep the type safety guarantees and make it impossible to call the function with values >31, but the names of the variants won't be pretty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions