carbon windows and NSWindow initWithWindowRef:
carbon windows and NSWindow initWithWindowRef:
- Subject: carbon windows and NSWindow initWithWindowRef:
- From: email@hidden
- Date: Thu, 28 Feb 2002 21:07:41 -0800
I'm trying to do some crazy things with NSWindow's created via
initWithWindowRef:
I built a carbon window and then the NSWindow out of it...
It shows fine, it paints fine, it even let me put an NSView inside it
which paints fine.
My problem is, nothing ever gets any input. I'm assuming that's because
it's expecting to be put into a carbon event loop someplace... but I
guess I was assuming that once I hooked up my NSWindow to it, I'd get
basic input.
I tried using a subclass of NSWindow so I could do my own event
management, but when I tried, I got this: "initWithWindowRef: is not
currently supported for NSWindow subclasses".
NSApp knows about the window, because when I print NSApp windows] I see
"<NSCarbonWindow: 0x165b80>"
I've tried creating carbon document windows, which show up just fine,
trafficlights and all. but they also get no input.
Here's the code... it's AMAZING how much faster this window is drawn
than a standard borderless NSWindow... (since you can't move the window
in my test here, grab say project builder and move it around behind the
red window)
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
@interface MyView : NSView
@end
@implementation MyView : NSView
- (void)drawRect:(NSRect)r
{
[[[NSColor redColor] colorWithAlphaComponent: 0.5] set];
NSFillRect(r);
}
- (void)mouseDown:(NSEvent *)e
{
NSLog(@"mouseDown");
}
@end
@interface Controller : NSObject
@end
@implementation Controller
- (void)awakeFromNib
{
WindowRef window;
Rect bounds = { 200, 300, 600, 800 };
OSStatus status = CreateNewWindow (kOverlayWindowClass, 0, &bounds,
&window);
NSWindow *win = [[NSWindow alloc] initWithWindowRef:window];
[win setBackgroundColor:[NSColor clearColor]];
[win setAlphaValue:0.99];
[win setOpaque:NO];
[win setHasShadow: YES];
[win makeKeyAndOrderFront:self];
[win setContentView:[[MyView alloc] init]];
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.