mouseDown时禁用mouseEntered事件(NSEvents Mac) [英] mouseEntered event disabled when mouseDown (NSEvents Mac)

查看:281
本文介绍了mouseDown时禁用mouseEntered事件(NSEvents Mac)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个NSButton类,当将鼠标悬停在按钮上时,它很高兴地检测到mouseEntered和mouseExited事件.但是,一旦发生mouseDown事件,只要将其按下,就不会再调用mouseEntered事件,直到抬起鼠标按钮为止.

因此,当调用mouseDown事件时,将鼠标悬停在其他按钮上直到我放开最初的mouseDown时,将不再调用mouseEntered或MouseExited事件,也不会调用mouseDown.

因此,我想检测一下鼠标在按下的同时何时进入.

解决方案

原来,我只需要将NSTrackingEnabledDuringMouseDrag添加到我的NSTrackingAreaOptions中即可.现在,使用鼠标向下拖动时会触发mouseEntered和mouseExited事件.

I have created an NSButton class, and when rolling over my buttons it happily detects mouseEntered and mouseExited events. But as soon as the mouseDown event occurs, so long as the mouse it down, mouseEntered events are no longer called until the mouse button is lifted.

So, when the mouseDown event is called, mouseEntered or MouseExited events are no longer called, nor is mouseDown called when rolling over other buttons until I let go of the initial mouseDown.

So I would like to detect when my mouse enters while the mouse is down as well.

解决方案

Turns out I just needed to add NSTrackingEnabledDuringMouseDrag to my NSTrackingAreaOptions. mouseEntered and mouseExited events now fire when dragging with mouse down.

这篇关于mouseDown时禁用mouseEntered事件(NSEvents Mac)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆