Re: [Pyobjc-dev] method swizzing
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2009-05-23 06:11:13
|
On 22 May, 2009, at 18:00, Jason Foreman wrote: > On Fri, May 22, 2009 at 8:51 AM, Daniel Ashbrook > <an...@cc...> wrote: >> I'm trying to make my program log every event that happens. I'm >> probably doing it wrong. What I'm trying is: >> >> oldIMP = NSResponder.instanceMethodForSelector_('mouseDown:') >> newIMP = objc.selector(lambda self, e: NSLog('%s: %s'%(self,e)), >> selector=oldIMP.selector, signature=oldIMP.signature) >> objc.classAddMethod(NSResponder, 'mouseDown:', newIMP) >> >> This works great - but only for clicking in places on the window that >> don't already do anything. When I click on a NSButton, for example, I >> don't get anything logged. >> >> I can go through and do the above for every subclass of NSResponder >> in >> my program, but that gets a little bit pesky, especially because it >> looks like I'd have to separately do it for things like the headers >> of >> NSTableViews and so forth. >> >> Is there a better way? > > Swizzling sendEvent: in NSApplication might work better, as I think > everything will go through that before being dispatched to a > responder. CoreGraphics has event traps that might also be useful for this. Ronald > > > Jason > > ------------------------------------------------------------------------------ > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity > professionals. Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp asthey present alongside digital heavyweights like > Barbarian > Group, R/GA, & Big Spaceship. http://www.creativitycat.com > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |