Layered views and drawRect
Layered views and drawRect
- Subject: Layered views and drawRect
- From: Julian Pellico <email@hidden>
- Date: Sun, 12 Dec 2004 15:07:51 -0800
Hi list,
In a nib I have a view hierarchy that looks like this:
NSWindow
->NSView (content view)
--->NSTextField
--->NSScrollView
----->ABView
At runtime I make sure the text field is ordered on top among its siblings.
I have a string in the text field that I'd like to be displayed
initially, but disappears on a successful drag. My plan is, on a
successful drag, to hide the text field.
I also want to show highlighting for the drag. In ABView, I have a
drawRect: method like so:
- (void)drawRect:(NSRect)rect
{
static const float BORDER_THICKNESS = 2.0;
if (highlighted) {
NSRect bounds = [self bounds];
NSLog(@"bounds: %@", NSStringFromRect([self bounds]));
NSBezierPath* path = [NSBezierPath bezierPathWithRect:
NSMakeRect(bounds.origin.x + BORDER_THICKNESS, bounds.origin.y +
BORDER_THICKNESS,
bounds.size.width - BORDER_THICKNESS * 2, bounds.size.height -
BORDER_THICKNESS * 2)];
[[NSColor selectedControlColor] set];
[path setLineWidth: BORDER_THICKNESS * 2];
[path stroke];
}
}
When a drag enters, I set the highlighted flag. As soon as drawRect is
run with highlighted = YES, the string in the text field is no longer
visible. My guess is it's drawn over. Why would this be the case?
ABView is not the frontmost view, and I would think that
-[NSBezierPath stroke] wouldn't paint over the whole rect anyway. Can
anyone shed some light on this?
Thanks
Julian
_______________________________________________
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