NSTextField: mystery line drawing outside focus ring?

  • I have a set of NSTextFields that are subviews of a custom view that
    has a colored background. The text fields have their background color
    set to the same color as the superview's background color. When their
    window is initially displayed, a black line is drawn around the first
    text field, just outside the focus ring. Tabbing to other text fields
    draws other lines and redrawing their superview erases the mystery
    lines.

    Has anybody seen this sort of behavior and/or know what I can do to
    keep them from appearing? I've attached a mini-screenshot showing
    what I'm seeing.

    steve
  • On 2007 Sep, 26, at 7:51, Steve Christensen wrote:

    > Has anybody seen this sort of behavior and/or know what I can do to
    > keep them from appearing? I've attached a mini-screenshot showing
    > what I'm seeing.

    Not quite, but I've caused similar artifacts in my custom views by
    cropping the size of the view, making changes to what remains and
    THEN invoking -setNeedsDisplay.  Stuff which was inside the view
    before but outside the view after the crop remains on the screen.  It
    makes sense that redrawing the superview fixes the problem.  Look at
    the whole life cycle of those NSTextFields.
  • This looks like a symptom of treating the rect passed to drawRect: as
    if it is the bounds of the view.

    Does your custom view draw a border around itself?  Are you drawing
    the border around the rect passed to drawRect:?  That won't work -
    that rectangle is a region within the view that is dirty and should be
    redrawn.  You likely want to position the border with respect to [self
    bounds].

    On 9/26/07, Steve Christensen <punster...> wrote:
    > I have a set of NSTextFields that are subviews of a custom view that
    > has a colored background. The text fields have their background color
    > set to the same color as the superview's background color. When their
    > window is initially displayed, a black line is drawn around the first
    > text field, just outside the focus ring. Tabbing to other text fields
    > draws other lines and redrawing their superview erases the mystery
    > lines.
    >
    > Has anybody seen this sort of behavior and/or know what I can do to
    > keep them from appearing? I've attached a mini-screenshot showing
    > what I'm seeing.
    >
    > steve
    >
    >
  • All my custom view does is fill itself with a particular color. The
    NSTextFields are subviews of my custom view, but they are not custom
    classes themselves.

    On Sep 26, 2007, at 11:43 PM, Ken Ferry wrote:

    > This looks like a symptom of treating the rect passed to drawRect: as
    > if it is the bounds of the view.
    >
    > Does your custom view draw a border around itself?  Are you drawing
    > the border around the rect passed to drawRect:?  That won't work -
    > that rectangle is a region within the view that is dirty and should be
    > redrawn.  You likely want to position the border with respect to [self
    > bounds].
    >
    > On 9/26/07, Steve Christensen <punster...> wrote:
    >> I have a set of NSTextFields that are subviews of a custom view that
    >> has a colored background. The text fields have their background color
    >> set to the same color as the superview's background color. When their
    >> window is initially displayed, a black line is drawn around the first
    >> text field, just outside the focus ring. Tabbing to other text fields
    >> draws other lines and redrawing their superview erases the mystery
    >> lines.
    >>
    >> Has anybody seen this sort of behavior and/or know what I can do to
    >> keep them from appearing? I've attached a mini-screenshot showing
    >> what I'm seeing.
    >>
    >> steve
  • On Sep 26, 2007, at 5:19 PM, Jerry Krinock wrote:

    > On 2007 Sep, 26, at 7:51, Steve Christensen wrote:
    >
    >> Has anybody seen this sort of behavior and/or know what I can do
    >> to keep them from appearing? I've attached a mini-screenshot
    >> showing what I'm seeing.
    >
    > Not quite, but I've caused similar artifacts in my custom views by
    > cropping the size of the view, making changes to what remains and
    > THEN invoking -setNeedsDisplay.  Stuff which was inside the view
    > before but outside the view after the crop remains on the screen.
    > It makes sense that redrawing the superview fixes the problem.
    > Look at the whole life cycle of those NSTextFields.

    Except that the NSTextFields are not custom classes; they are simply
    subviews of a custom NSView. They each have a custom NSFormatter
    attached, but that's it.

    steve
  • On Sep 27, 2007, at 7:04 AM, Steve Christensen wrote:

    > On Sep 26, 2007, at 11:43 PM, Ken Ferry wrote:
    >
    >> This looks like a symptom of treating the rect passed to drawRect: as
    >> if it is the bounds of the view.
    >>
    >> Does your custom view draw a border around itself?  Are you drawing
    >> the border around the rect passed to drawRect:?  That won't work -
    >> that rectangle is a region within the view that is dirty and
    >> should be
    >> redrawn.  You likely want to position the border with respect to
    >> [self
    >> bounds].
    >
    > All my custom view does is fill itself with a particular color. The
    > NSTextFields are subviews of my custom view, but they are not
    > custom classes themselves.

    OK, it's still early in the AM so what Ken said didn't sink in until
    after sending my reply. Yeah, I'm drawing a border in my custom view
    and was using the passed in rect. Using [view bounds] fixed it.
    Thanks for the help!

    steve
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today