Edit AllPages

Currently i have a semitransparent General/NSView subclass which contains other custom General/NSView’s. The interior views draw properly the first time, but then when they are redrawn they have weird fully transparent sections around the curved corners. This also happens with a normal General/NSTextField.

Images of what the window looks like before and after the redraw: BEFORE: AFTER:

The redraw of the views is caused by either the user dragging files on the rounded views or clicking on the clear text field.

Here is the code for how i add the rounded views and text field, called during my General/AppController

-(void)insertViews { int i = 0; for (i=0;i<[allItems count];i++) { myView newView = General/myView alloc] initWithFrame:[[NSMakeRect(20,i70,[mainWindow frame].size.width-40,70)]; [myView setAutoresizingMask:General/NSViewWidthSizable]; General/mainWindow contentView] addSubview:myView]; [myView release]; }

myClearTextField *textField = [[myClearTextField alloc] initWithFrame:[[NSMakeRect(50,[mainWindow frame].size.height - (i*71),[mainWindow frame].size.width-40,20)];
General/mainWindow contentView] addSubview:textField]; }

Here is how the rounded view redraws itself:

If anybody has any idea how/why this is happening, please help. Thanks General/JohnCassington

Eliminate the initial call to General/NSEraseRect. It’s pointless and probably the cause of the problem.

Definitely the cause of the problem. Every view is drawing to the same destination, which is the window backing store. When it comes time to redraw a rect, Cocoa erases that region of the backing store and asks each view that sits over that region to draw in turn (modulo optimizations for opaque views). If you paint with clear color (or erase rect) in composite copy mode, which is what you’re doing, you’re knocking out any drawing that superviews may have done.

Thank, i think i understand what you are saying. However, i’m not quite sure what method i should use. I took out all three lines…

General/NSEraseRect([self frame]); General/[[NSColor blackColor] set]; General/NSRectFill([self frame]);

… but it still draws in the same way as before (see second image above). I think it may have something to do with a General/NSView being placed over the contentView of the General/NSWindow. I do this to create the rounded effect.

What do you mean “placed over”? Overlapping sibling views are not supported, and may lead to this sort of problem. There should be no need for overlapping siblings.. the smaller views should be subviews of the larger.

A hint here: add: printf(“%f, %f, %f, %f\n”, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); in - (void)drawRect:(General/NSRect)rect{} Then look at the output. I think you will understand ;). I will put more info when I have time.