NSEvent and Magic Mouse

a 夏天 提交于 2019-12-08 13:49:34

I was able to distinguish between a scroll wheel on a mouse (not a Magic Mouse, but I suspect it will still work) and a trackpad using NSEvent's subtype:

enum {
   NSMouseEventSubtype           = NX_SUBTYPE_DEFAULT,
   NSTabletPointEventSubtype     = NX_SUBTYPE_TABLET_POINT,
   NSTabletProximityEventSubtype = NX_SUBTYPE_TABLET_PROXIMITY
   NSTouchEventSubtype             = NX_SUBTYPE_MOUSE_TOUCH
};

You should handle scrollWheel for the Magic Mouse and add a NSMagnificationGestureRecognizer for the pinch gesture on the trackpad. The two do not conflict with each-other but the swipe-scroll on the trackpad will trigger scrollWheel.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!