美文网首页
Mac开发键盘 & 鼠标 事件监听

Mac开发键盘 & 鼠标 事件监听

作者: 杯中怎可无酒 | 来源:发表于2020-11-20 17:44 被阅读0次

    这里是common+shift+鼠标右键连续点击5次

        DefWeakSelf
        self.debugMonitorEvent = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskRightMouseDown | NSEventMaskKeyDown | NSEventMaskFlagsChanged handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
            BOOL isKeyWindow = weakSelf.window.isKeyWindow;
            BOOL isActive = [NSRunningApplication currentApplication].active;
            if (isKeyWindow && isActive) {
                if (((event.modifierFlags & NSEventModifierFlagCommand) != 0 && (event.modifierFlags & NSEventModifierFlagShift) != 0)) {
                    if (event.type == NSEventTypeRightMouseDown) {
                        if (weakSelf.mouseClickCount < 5) {
                            weakSelf.mouseClickCount++;
                        }
                        if (weakSelf.mouseClickCount >= 5) {
                            weakSelf.mouseClickCount = 0;
                            [LSChangePlatformHelper showChangeServiceAlertWithWindow:weakSelf.window];
                        }
                    }else {
                        weakSelf.mouseClickCount = 0;
                    }
                }else {
                    weakSelf.mouseClickCount = 0;
                }
            }else {
                weakSelf.mouseClickCount = 0;
            }
            return event;
        }];
    

    相关文章

      网友评论

          本文标题:Mac开发键盘 & 鼠标 事件监听

          本文链接:https://www.haomeiwen.com/subject/moqjiktx.html