-
-
Save jspahrsummers/9054650 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[NSWindow ex_patchInstanceSelector: @selector(sendEvent:) withReplacementBlock: ^(EXPatchIMP *patch) { | |
return ^(NSEvent *event) { | |
NSWindow *window = (__bridge NSWindow *) patch->self; | |
if (window != self.window && [event type] == NSLeftMouseUp && [window isKeyWindow]) { | |
/* The last view seen */ | |
static NSView *lastView = nil; | |
NSPoint point = [window.contentView convertPoint: [event locationInWindow] fromView: nil]; | |
NSView *hitView = [window.contentView hitTest: point]; | |
/* Only send a notification when the view changes */ | |
if (hitView != nil && hitView != lastView) { | |
lastView = hitView; | |
[[NSNotificationCenter defaultCenter] postNotificationName: EXViewAnalyzerTargetedViewNotification object: hitView]; | |
} | |
} | |
((void (*)(id, SEL, NSEvent *))patch->origIMP)(event); | |
}; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment