• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
problems with NSTextField destroying background
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problems with NSTextField destroying background


  • Subject: problems with NSTextField destroying background
  • From: Memo Akten <email@hidden>
  • Date: Wed, 11 Mar 2009 18:28:48 +0000

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: problems with NSTextField destroying background
      • From: Benjamin Stiglitz <email@hidden>
  • Prev by Date: Re: setFrame: not working in custom event loop
  • Next by Date: Re: Garbage collected and non-garbage collected
  • Previous by thread: Cocoaheads Lake Forest (92630) meeting 3/11/2009 (tonight!) at 7 pm on "Modeling a Game with the Cocoa Frameworks"
  • Next by thread: Re: problems with NSTextField destroying background
  • Index(es):
    • Date
    • Thread