NSButtons have drawing "artefacts" around them when clicked on a window/custom view bezel

  • I have a window/custom view combination that draws a bezel type
    window on the screen, with rounded corners.

    The window has a stylemask  NSBorderlessWindowMask

    and the following settings:

    [self setLevel:NSStatusWindowLevel];
    [self setBackgroundColor: [NSColor clearColor]];
    //        [self setBackgroundColor: [NSColor blackColor]];
    [self setHasShadow:NO];
    [self setMovableByWindowBackground:YES];
    [self setOpaque:NO];

    The custom view is Matt Gemmell's RoundedView, and simply draws a
    rounded rectangle in its drawRect: method, in black, with an
    intermediate alpha value.

    This produces a nice semi-transparent bezel type window, with rounded
    corners.

    I have a couple of standard NSButtons sitting on top of the custom
    view. When these are clicked, the non-button portion of the control
    (i.e. within the buttons rect, but outside the actual button itself)
    gets mostly filled in in white, and remains that way. This is very
    unattractive. A help button seems to have a slight artefact in its
    rect right from the get-go.

    I can get rid of this effect by either changing the setOpaque: call
    in the window to YES, or by ditching the rounded view, and changing
    the window background color to black (the commented out line above).
    Then the buttons behave normally. However, in either case, I lose my
    nice rounded corners.

    I guess I can somehow work around this by fiddling with the button
    cell's or something, but any pointers would be welcome.
  • On 18 Oct 2006, at 04:45, Martin Redington wrote:

    >
    > I have a window/custom view combination that draws a bezel type
    > window on the screen, with rounded corners.
    >
    > The window has a stylemask  NSBorderlessWindowMask
    >
    > and the following settings:
    >
    > [self setLevel:NSStatusWindowLevel];
    > [self setBackgroundColor: [NSColor clearColor]];
    > //        [self setBackgroundColor: [NSColor blackColor]];
    > [self setHasShadow:NO];
    > [self setMovableByWindowBackground:YES];
    > [self setOpaque:NO];
    >
    > The custom view is Matt Gemmell's RoundedView, and simply draws a
    > rounded rectangle in its drawRect: method, in black, with an
    > intermediate alpha value.
    >
    > This produces a nice semi-transparent bezel type window, with
    > rounded corners.
    >
    > I have a couple of standard NSButtons sitting on top of the custom
    > view.

    I think this is your problem.  Your buttons should not site on the
    custom view, but inside of it.

    Mike.

    > When these are clicked, the non-button portion of the control (i.e.
    > within the buttons rect, but outside the actual button itself) gets
    > mostly filled in in white, and remains that way. This is very
    > unattractive. A help button seems to have a slight artefact in its
    > rect right from the get-go.
    >
    > I can get rid of this effect by either changing the setOpaque: call
    > in the window to YES, or by ditching the rounded view, and changing
    > the window background color to black (the commented out line above).
    > Then the buttons behave normally. However, in either case, I lose
    > my nice rounded corners.
    >
    > I guess I can somehow work around this by fiddling with the button
    > cell's or something, but any pointers would be welcome.
    >
    >
    >
    >
    >
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    > 40gmail.com
    >
    > This email sent to <mike.abdullah...>
  • sorry, I should have been more precise.

    The buttons are children of the custom view, so they are "inside" it,
    rather than sitting on top.

    Window
        ContentView
            RoundedView
                NSButton

    On 18 Oct 2006, at 08:36, Mike Abdullah wrote:

    >
    > On 18 Oct 2006, at 04:45, Martin Redington wrote:
    >
    >>
    >> I have a window/custom view combination that draws a bezel type
    >> window on the screen, with rounded corners.
    >>
    >> The window has a stylemask  NSBorderlessWindowMask
    >>
    >> and the following settings:
    >>
    >> [self setLevel:NSStatusWindowLevel];
    >> [self setBackgroundColor: [NSColor clearColor]];
    >> //        [self setBackgroundColor: [NSColor blackColor]];
    >> [self setHasShadow:NO];
    >> [self setMovableByWindowBackground:YES];
    >> [self setOpaque:NO];
    >>
    >> The custom view is Matt Gemmell's RoundedView, and simply draws a
    >> rounded rectangle in its drawRect: method, in black, with an
    >> intermediate alpha value.
    >>
    >> This produces a nice semi-transparent bezel type window, with
    >> rounded corners.
    >>
    >> I have a couple of standard NSButtons sitting on top of the custom
    >> view.
    >
    > I think this is your problem.  Your buttons should not site on the
    > custom view, but inside of it.
    >
    > Mike.
    >
    >> When these are clicked, the non-button portion of the control
    >> (i.e. within the buttons rect, but outside the actual button
    >> itself) gets mostly filled in in white, and remains that way. This
    >> is very unattractive. A help button seems to have a slight
    >> artefact in its rect right from the get-go.
    >>
    >> I can get rid of this effect by either changing the setOpaque:
    >> call in the window to YES, or by ditching the rounded view, and
    >> changing the window background color to black (the commented out
    >> line above).
    >> Then the buttons behave normally. However, in either case, I lose
    >> my nice rounded corners.
    >>
    >> I guess I can somehow work around this by fiddling with the button
    >> cell's or something, but any pointers would be welcome.
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    >> 40gmail.com
    >>
    >> This email sent to <mike.abdullah...>
    >
previous month october 2006 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 31          
Go to today