Mac Cocoa How to scroll another App that under a view?

北城以北 提交于 2019-12-13 03:26:27

问题


I'm trying to make a screenshot capture App. The App will first place a semitransparent full screen dark view over other Apps, this will make other Apps not responding to mouse scrolling event. How can I set a view covers other Apps and keep them respond to scrolling event? Thanks.

  1. Ignore MyApp's dark view?

or

  1. Send event to other Apps in MyApp?
 -(void)scrollWheel:(NSEvent *)theEvent {
    NSLog(@"user scrolled %f horizontally and %f vertically", [theEvent deltaX], [theEvent deltaY]);
}

Edited:

Found a way to get a App's pid and Followed @Willeke's reference, write the following code, but not work.

-(void)scrollWheel:(NSEvent *)theEvent {
    [super scrollWheel:theEvent];

    CGEventRef wheelevent = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, theEvent.deltaY, theEvent.deltaX);

    // AppPid is gotten before mouse wheel scrolls
    CGEventPostToPid(AppPid, wheelevent);

    CFRelease(wheelevent);
}

来源:https://stackoverflow.com/questions/56955602/mac-cocoa-how-to-scroll-another-app-that-under-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!