Is there a way to detect a click and hold within a NSView? I want to trigger an event after holding the mouse button down for 0.5 sec - similar to a longPressGesture in iOS.

有帮助吗?

解决方案

I don't know of a specific selector for this, which is what it sounds like you're asking for, but you could, quite easily, handle this yourself.

Start a timer when the mouse down event occurs and when the amount of time has passed, react to it if the mouse up event did not occur before the specified elapsed time.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top