Mar 28, 2008

Possible Interface Builder bug with QCView in Leopard


A friend of mine was trying to embed a Quartz Composer composition into a Cocoa app, and he was having problems getting it to work properly. The composition responded to mouse events and it worked just fine within QC, but for some reason not within a QCView. I took a look at the project and he had done everything right, as far as I could tell; the "ForwardAllEvents" checkbox was checked. 

So, I decided to perform a little experiment. I added a view controller to the application with the QCView as an outlet.

Lo and behold, the eventForwardingMask was set to 1, not NSAnyEventMask as it should have been. The solution then presented itself: Set this value correctly in the -awakeFromNib and now the application worked properly
Here's the header file:

#import <cocoa/cocoa.h>
#import <quartzcomposer/qcview.h>

@interface MyViewController : NSObject {
IBOutlet QCView *myView;
}

@end

And here's the implementation:

#import "MyViewController.h"

@implementation MyViewController

- (void)awakeFromNib
{
NSLog(@"%d", [myView eventForwardingMask]);
[myView setEventForwardingMask:NSAnyEventMask];
NSLog(@"%d", [myView eventForwardingMask]);
}

@end

I'm going to file a bugreporter bug right away.


4 comments:

Steve Ballmer said...

You really need to forget this mac stuff and come over to Vista guy!

Felix MC said...

you don't know how much I love you :))
i've been looking for this for ages, I went through a dozen Xcode re-installs and projects rebuilts from ground up.
THANK YOU!! :DD

Anonymous said...

Did you get a response from Apple on this? It's still broken.

--Tim

Paul Franceus said...

No, No response. Did you try the workaround?