Hi All, I am creating everything programatically:
one custom NSWindow -> one NSView (my root view), that has multiple custom NSViews attached, in each one is an NSBox and NSTextField.

My problem is, I want the NSTextField to be transparent (and show the NSBox behind), but instead it's making a hole in the NSBox to show the desktop, what am I missing?

window and root view code:

-(id) initWithContentRect:(NSRect)windowRect {
        NSLog(@"TransparentWindow::initWithContentRect");
if(self = [super initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) {
                [self setOpaque:NO];
                [self setBackgroundColor:[NSColor clearColor]];
                [self setMovableByWindowBackground:NO];
                [self makeKeyAndOrderFront:nil];
                
                NSView *rootView = [[NSView alloc] initWithFrame:windowRect];
                [self setContentView:rootView];
                [rootView release];

                controller = [[Controller alloc] initWithView:rootView];
        }
        NSLog(@"/TransparentWindow::initWithContentRect");
        return self;
}       

Controller is just a custom NSObject which managers my data, and it creates a bunch of CustomViews:

- (id)initWithFrame:(NSRect)frame andData:(Data*)c {
    NSLog(@"CustomView::initWithFrame");
    self = [super initWithFrame:frame];
    if (self) {
                data = c;
NSRect myRect = NSMakeRect(0.0, 0.0, frame.size.width, frame.size.height);
                
                NSBox *bgView = [[[NSBox alloc] initWithFrame:myRect] 
autorelease];
                [bgView setBoxType:NSBoxCustom];
                [bgView setBorderType:NSLineBorder];
                [bgView setTitlePosition:NSNoTitle];
                [bgView setFillColor:[NSColor grayColor]];
                [self addSubview:bgView];
                
NSTextField *label = [[[NSTextField alloc] initWithFrame:NSMakeRect(0.0, frame.size.height/2, frame.size.width, TITLE_SIZE * 2)] autorelease];
                [label setEnabled:NO];
                [label setSelectable:NO];
                [label setBackgroundColor:[NSColor clearColor]];
[label setTextColor:[NSColor colorWithDeviceRed:TITLE_COLOR green:TITLE_COLOR blue:TITLE_COLOR alpha:1]];
                [label setTitleWithMnemonic:@"testing"];
                [label setAlignment:NSCenterTextAlignment];
                [label setFont:[NSFont fontWithName:@"Myriad Set" 
size:TITLE_SIZE]];
                [label setBordered:NO];
                [self addSubview:label];
    }
        NSLog(@"/CustomView::initWithFrame");
    return self;
}
        

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to