• 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
Changing contentView of NSPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changing contentView of NSPanel


  • Subject: Changing contentView of NSPanel
  • From: Christian Schneider <email@hidden>
  • Date: Tue, 8 Mar 2005 16:11:21 +0100

Hi all,

I've got a custom NSPanel the contentView of which I want to have a
black border. I created a subclass of NSView for that with the
following -drawRect:

- (void)drawRect:(NSRect)rect
{
    [super drawRect:rect];
    [NSBezierPath setDefaultLineWidth:1.0];
}

I am setting the view as contentView of my panel in the panel's awakeFromNib:

- (void) awakeFromNib
{
	NSRect contentRect = [[self contentView] frame];
	GFFBorderedView *newContentView = [[GFFBorderedView alloc]
initWithFrame:contentRect];
	NSArray *subviews = [[self contentView] subviews];
	int i;

	for( i=0; i<[subviews count]; i++ ){
		[newContentView addSubview:[subviews objectAtIndex:i]];
	}
	[self setContentView:newContentView];
	[newContentView autorelease];
}

If I leave out the part concerning the subview my application
immediately crashes after launching. If I leave it in, it crashes
later. My application is structured in such a way that the main
components used to do work are loaded from bundles on demand. If I
load such a bundle the app crashes. If I don't load one, there's one
window that is available on its own which I can open. That window
opens up fine and even draws the border around the contentView; the
thing is that a lot of the window's interface elements are missing.
And no, I wouldn't say that there's a logic to which elements are
missing. All of the window's elements are direct subviews of the
content view.

When I look at the stack trace of the crash after I try to load a
bundle I'd say the app crashes when it tries to access a UI element
which should have been transferred to my new content view (but
apparently wasn't).

So, anyway, I searched for advice on how to implement a custom content
view but didn't find much.

Any pointers welcome.

chris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Changing contentView of NSPanel
      • From: daniel <email@hidden>
  • Prev by Date: Re: Minimum window size?
  • Next by Date: Re: Preferences....
  • Previous by thread: MEETING ANNOUNCEMENT: CocoaHeads in Boston/Worcester MA and Pittsburgh PA Thursday March 10
  • Next by thread: Re: Changing contentView of NSPanel
  • Index(es):
    • Date
    • Thread