开发者

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

开发者 https://www.devze.com 2023-02-26 02:44 出处:网络
Is there a way to get - (void)beginGestureWithEvent:(NSEvent *)event and - (void)endGestureWithEvent:(NSEvent *)event

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

精彩评论

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