BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Subviews use superview's `drawRect' method?

    5 answers - 761 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I'm getting some weirdness with NSViews and subviews. Here's a
    screenshot of what I'm talking about.
    http://www.ilstu.edu/~dsorres/nsview_weirdness.png
    Check out the box around the button that says `Finish'. That border
    draws when I press the button, and it refuses to go away. The
    button's superview, is the box with the 1.5 pixel-thick border, which
    I draw with an `NSBezierPath' in the `drawRect' method. I've run into
    this type of thing before, and putting a `[view setNeedsDisplay:YES]'
    in the right place does the trick. But in this case, it's not working.
    Why are the subviews apparently using the superview's `drawRect'
    method when they're dirty?
  • No.1 | | 1465 bytes | |

    16 Aug 2005, at 9:49 AM, Damien Sorresso wrote:

    I'm getting some weirdness with NSViews and subviews. Here's a
    screenshot of what I'm talking about.

    http://www.ilstu.edu/~dsorres/nsview_weirdness.png

    Check out the box around the button that says `Finish'. That border
    draws when I press the button, and it refuses to go away. The
    button's superview, is the box with the 1.5 pixel-thick border,
    which I draw with an `NSBezierPath' in the `drawRect' method. I've
    run into this type of thing before, and putting a `[view
    setNeedsDisplay:YES]' in the right place does the trick. But in
    this case, it's not working.

    Why are the subviews apparently using the superview's `drawRect'
    method when they're dirty?

    More to the point: Does the box drawRect: stroke the framing
    rectangle based on the NSRect passed to it? So that when the button
    region is dirty it frames the button?

    -- F

    --
    Fritz Anderson fritza (AT) uchicago (DOT) edu
    Mac Programmer +1 773 834-1499
    University of Chicago
    Networking Services and Information Technologies

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.2 | | 1821 bytes | |

    I'm not sure of the "why," but I have encountered this as well.

    I've been able to work around it by drawing the border using [self
    bounds] rather than the rect variable that drawRect: gets passed.
    -- August

    Aug 16, 2005, at 10:35 AM, Fritz Anderson wrote:

    16 Aug 2005, at 9:49 AM, Damien Sorresso wrote:
    >
    >
    >I'm getting some weirdness with NSViews and subviews. Here's a
    >screenshot of what I'm talking about.
    >>

    >http://www.ilstu.edu/~dsorres/nsview_weirdness.png
    >>

    >Check out the box around the button that says `Finish'. That
    >border draws when I press the button, and it refuses to go away.
    >The button's superview, is the box with the 1.5 pixel-thick
    >border, which I draw with an `NSBezierPath' in the `drawRect'
    >method. I've run into this type of thing before, and putting a `
    >[view setNeedsDisplay:YES]' in the right place does the trick. But
    >in this case, it's not working.
    >>

    >Why are the subviews apparently using the superview's `drawRect'
    >method when they're dirty?
    >>

    >

    More to the point: Does the box drawRect: stroke the framing
    rectangle based on the NSRect passed to it? So that when the button
    region is dirty it frames the button?

    -- F

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.3 | | 659 bytes | |

    16 Aug, 2005, at 10:35 AM, Fritz Anderson wrote:
    More to the point: Does the box drawRect: stroke the framing
    rectangle based on the NSRect passed to it? So that when the button
    region is dirty it frames the button?

    Here's the code for the `drawRect' method.
    - (void)drawRect:(NSRect)rect {
    NSBezierPath *fill = [NSBezierPath bezierPathWithRect:rect];

    [[NSColor colorWithCalibratedRed:1.0f
    green:1.0f
    blue:1.0f
    alpha:0.5f] set];

    [fill fill];

    [[NSColor grayColor] set];

    [fill setLineWidth:1.5f];
    [fill stroke];
    }

    Should I be stroking `bounds' and not `rect'?
  • No.4 | | 295 bytes | |

    16 Aug, 2005, at 10:57 AM, August Trometer wrote:
    I'm not sure of the "why," but I have encountered this as well.
    I've been able to work around it by drawing the border using [self
    bounds] rather than the rect variable that drawRect: gets passed.
    Yep! That did it.
  • No.5 | | 929 bytes | |

    Aug 16, 2005, at 12:03 PM, Damien Sorresso wrote:

    16 Aug, 2005, at 10:35 AM, Fritz Anderson wrote:
    >
    >More to the point: Does the box drawRect: stroke the framing
    >rectangle based on the NSRect passed to it? So that when the
    >button region is dirty it frames the button?
    >

    Here's the code for the `drawRect' method.

    []

    Should I be stroking `bounds' and not `rect'?

    If you want to draw your bounds, yes.

    The rect you are passed is the aggregate dirty rect, not your bounds.

    #//apple_ref/doc/uid/
    20000014-BBCDGJHF

    Jim

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com

Re: Subviews use superview's `drawRect' method?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 8 =
QUESTION ON "BSD"

EMSDN.COM