Created
February 17, 2014 16:56
-
-
Save landonf/9054459 to your computer and use it in GitHub Desktop.
Example patch master usage ( https://opensource.plausible.coop/src/projects/XC/repos/excode-plugin/browse/eXcode/EXPatchMaster.m?until=618f5fc0c2cbe5f4d8027d49ea61afddeb864a6e )
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
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
[NSWindow ex_patchInstanceSelector: @selector(sendEvent:) withReplacementBlock: ^(EXPatchIMP *patch, 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]; | |
} | |
} | |
EXPatchIMPFoward(patch, void (*)(id, SEL, NSEvent *), event); | |
}]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment