In hopes of creating a rollover effect on a button, I created a subclass of NSButton called Button.
Button.h:
#import <AppKit/AppKit.h>
@interface Button : NSButton {
}
- (void)mouseEntered:(NSEvent *)theEvent;
- (void)mouseExited:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)ev;
- (void)mouseUp:(NSEvent *)theEvent;
@end
Button.m: #import "Button.h"
@implementation Button
- (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if(self != nil) {
NSLog(@"btn init");
}
return self;
}
- (void)mouseEntered:(NSEvent *)theEvent{
NSLog(@"mouseEntered");
[self setImage:[NSImage imageNamed:@"lockIcon_2.png"]];
[self setNeedsDisplay];
}
- (void)mouseExited:(NSEvent *)theEvent{
[self setImage:[NSImage imageNamed:@"lockIcon_1.png"]];
NSLog(@"mouseExited");
[self setNeedsDisplay];
}
- (void)mouseDown:(NSEvent *)ev {
NSLog(@"mouseDown!");
}
- (void)mouseUp:(NSEvent *)ev {
NSLog(@"mouseUp!");
}
@end
With the code above, every time I click on a button I see "mouseDown" in the logs, but I don't see "mouseEntered" nor "mouseExited" (and of course don't see the image change)?? Sadly, I know I'm missing something obvious, but I'm just not seeing it... ???