Custom dimmed graphic for NSButton?

  • I have an NSButton that has custom images for pressed and normal states all
    done only in IB. I want to have a custom graphic for the dimmed state as
    well. I am guessing the only way is to subclass NSButton... What do I need
    to override to only customize the dimmed state?

    Thanks,

    Trygve
  • On Oct 14, 2006, at 10:52 PM, Trygve Inda wrote:

    > I have an NSButton that has custom images for pressed and normal
    > states all
    > done only in IB. I want to have a custom graphic for the dimmed
    > state as
    > well. I am guessing the only way is to subclass NSButton... What do
    > I need
    > to override to only customize the dimmed state?

    I think something like this in an NSButton subclass should be
    sufficient:

    //  typed in mail, may have errors
    - (void)setEnabled:(BOOL)enabled
    {
      if (enabled != [self enabled]) {
        [self setImage:enabled ? [NSImage
    imageNamed:@"activeButtonImage"] : [NSImage
    imageNamed:@"dimmedButtonImage"]];
        [super setEnabled:enabled];
      }
    }
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