Skip to content

Instantly share code, notes, and snippets.

@j4johnfox
Created November 19, 2008 21:12
Show Gist options
  • Save j4johnfox/26720 to your computer and use it in GitHub Desktop.
Save j4johnfox/26720 to your computer and use it in GitHub Desktop.
@import <AppKit/CPButton.j>
@implementation MMSToolbarButton : CPButton
{
CPString identifier @accessors;
CPString buttonType @accessors;
}
- (id)initWithFrame:(CPRect)frame
{
self = [super initWithFrame: frame];
[self setState:CPOffState];
return self;
}
- (void)mouseUp:(CPEvent)anEvent
{
[super mouseUp:anEvent];
if ([self buttonType] == CPToggleButton)
{
[self swapImages];
[self setNextState];
}
}
- (void)swapImages
{
var nextAltImage = [self image];
var nextImage = [self alternateImage];
[self setImage:nextImage];
[self setAlternateImage:nextAltImage];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment