Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试找到一种方法来触发 MouseEntered 事件,或者至少检测在进入该区域时何时按下鼠标按钮。
如果鼠标在按下左键的情况下进入跟踪区域,有没有办法检测到这个事件?
有没有我可以用来做同样事情的不同事件?
假设您已将跟踪区域设置为接收鼠标进入和退出事件,您可以执行以下操作:
- (void)mouseEntered:(NSEvent*)theEvent { if ([[NSApp currentEvent] type] == NSLeftMouseDown) { NSLog(@"mouse is pressed"); } }