wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.2k stars 291 forks source link

kCGEventOtherMouseUp triggers mousedown, not mouseup #262

Closed arcusfelis closed 3 years ago

arcusfelis commented 3 years ago

Could be a bug when processing kCGEventOtherMouseUp event.

Current Behavior

mouse down triggered twice on click for other buttons.

Expected Behavior

mouseup triggered

Possible solution

https://github.com/wilix-team/iohook/blob/master/libuiohook/src/darwin/input_hook.c#L1043

        case kCGEventOtherMouseUp:
            // Extra mouse buttons.
            if (CGEventGetIntegerValueField(event_ref, kCGMouseEventButtonNumber) < UINT16_MAX) {
                uint16_t button = (uint16_t) CGEventGetIntegerValueField(event_ref, kCGMouseEventButtonNumber) + 1;

                // Add support for mouse 4 & 5.
                if (button == 4) {
                    unset_modifier_mask(MOUSE_BUTTON4);
                }
                else if (button == 5) {
                    unset_modifier_mask(MOUSE_BUTTON5);
                }

                process_button_pressed(timestamp, event_ref, button); // should be process_button_released probably
            }
            break;

Your Environment

ash0x0 commented 3 years ago

Not really sure if this is a current issue but if I understand correctly, this triggers mousedown when mouseup is clicked? I haven't been able to repro this so closing. If still an issue please provide env details to repro.