What's wrong with my drawInteriorWithFrame implementation ?

  • Hi list !

    I'm implementing my own NSButton subclass, currently only drawing a
    string, and have a strange problem when I click on my button : each
    time I click on my button, the string appears darker, just like if it
    was drawn above itself again and again !

    Here is the only thing I have subclassed in my NSButtonCell subclass
    (none my NSButton subclass method has been subclassed for the moment) :

    - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
    {
        [self drawInteriorWithFrame:cellFrame inView:controlView];
    }

    - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
    controlView
    {
        [[self title] drawInRect:cellFrame withAttributes:nil];
    }

    It was just supposed to be a test, that's why it is so simple. But
    even with such a simple code, it doesn't work as expected.

    I don't understand why the string draw above itself each time I click
    on the button. Is there something I should had to erase the previous
    content of the cell ?

    Thanks,

    Eric.
  • OK, sorry, I found where was the problem : I forgot to subclass -
    (BOOL)isOpaque on my NSButton subclass so that it returns NO (my
    NSButton is partially transparent).

    Eric.

    Le 7 sept. 05 à 19:15, Eric Morand a écrit :

    > Hi list !
    >
    >
    > I'm implementing my own NSButton subclass, currently only drawing a
    > string, and have a strange problem when I click on my button : each
    > time I click on my button, the string appears darker, just like if
    > it was drawn above itself again and again !
    >
    > Here is the only thing I have subclassed in my NSButtonCell
    > subclass (none my NSButton subclass method has been subclassed for
    > the moment) :
    >
    >
    > - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
    > {
    > [self drawInteriorWithFrame:cellFrame inView:controlView];
    > }
    >
    > - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
    > controlView
    > {
    > [[self title] drawInRect:cellFrame withAttributes:nil];
    > }
    >
    >
    >
    > It was just supposed to be a test, that's why it is so simple. But
    > even with such a simple code, it doesn't work as expected.
    >
    >
    > I don't understand why the string draw above itself each time I
    > click on the button. Is there something I should had to erase the
    > previous content of the cell ?
    >
    >
    >
    > Thanks,
    >
    >
    > Eric.
    > _______________________________________________
    > 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/<eric.morand...>
    >
    > This email sent to <eric.morand...>
    >
previous month september 2005 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
MindNode
MindNode offered a free license !