• 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
Layered views and drawRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Layered views and drawRect
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: How can I implement labels without the overhead of an NSTextField?
  • Next by Date: Re: How can I implement labels without the overhead of an NSTextField?
  • Previous by thread: Re: So whats the deal with NSBrowser?
  • Next by thread: Re: Layered views and drawRect
  • Index(es):
    • Date
    • Thread