rendered paste bodyFirst subclass: the NSView
---------------------------------
#import "customViewer.h"
@implementation customViewer
-(void)awakeFromNib
{
image = [NSImage imageNamed:@"bgImageOne"];
[self setNeedsDisplay:YES];
}
-(void)drawRect:(NSRect)rect
{
[[NSColor clearColor] set];
NSRectFill([self frame]);
[image compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
}
- (void)mouseDown:(NSEvent *)theEvent
{
BOOL isDoubleClick = [theEvent clickCount] == 2;
if(isDoubleClick == YES)
{
image = [NSImage imageNamed:@"bgImage_over"];
[self setNeedsDisplay:YES];
}
}
-(void)mouseUp:(NSEvent *)theEvent
{
image = [NSImage imageNamed:@"bgImageOne"];
[self setNeedsDisplay:YES];
}
-(void)setNewImage // THIS is the method I want to call from the other class.
{
NSLog(@"image method called");
}
@end
The NSTextField subclass:
#import "customTextField.h"
@implementation KGSerialFieldLabel
-(void)mouseDown:(NSEvent *)event
{
BOOL isDoubleClick = [event clickCount] == 2;
if(isDoubleClick)
{
[customViewOutlet setNewImage]; // The message that should be set to customView (customViewOutlet is an IBOutlet connected to customViewer)
}
}
@end