开发者

Way to get beginGestureWithEvent/endGestureWithEvent if window isn't frontmost

Is there a way to get

- (void)beginGestureWithEvent:(NSEvent *)event

and

- (void)endGestureWithEvent:(NSEvent *)event

calls to a view even if the containing window is in the background? It seems these calls开发者_运维问答 are only delivered to windows if they are key.


In general no. In Leopard and SnowLeopard, gestures are intended to target only the foreground window. As you discovered, the window server will not even send gesture events to background applications.

You could instal an event tap, but those events don't look exactly their the NS equivalents. All the data is there, though, if you really want to dig into it.

Please file a radar asking for this along with why this would be useful.


But here's a workaround:

Add a tracking area to your view bounds with options NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways

…and activate your application upon mouseEntered:

It's non-standard but it will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜