i'm having trouble making the pasteboard accept my cropped version of the NSView's NSColor. kinda lost and it's making me a bit crazy...
also, but least important, i'd like to have an outline around my dragged image because you can't really see that it's being dragged until the user drags it outside the window (as it's just a color). how can i add an outline or highlight to the mouseDragged method so that the user can see the dragged image?
mouseDragged method:
warning states that "self" (which is my NSView subclass) may not respond to NSPasteBoard?? it will accept "fillColor" which is my NSColor, but it still doesn't copy it to the pasteboard...
also, but least important, i'd like to have an outline around my dragged image because you can't really see that it's being dragged until the user drags it outside the window (as it's just a color). how can i add an outline or highlight to the mouseDragged method so that the user can see the dragged image?
mouseDragged method:
Code:
- (void)mouseDragged:(NSEvent *)event
{
NSPoint down = [mouseDownEvent locationInWindow];
NSPoint drag = [event locationInWindow];
float distance = hypot(down.x - drag.x, down.y - drag.y);
if (distance < 2)
{
return;
}
NSSize size = NSMakeSize(64, 64);
NSRect imageBounds;
imageBounds.origin = NSZeroPoint;
imageBounds.size = size;
NSImage *anImage = [[NSImage alloc] initWithSize:size];
[anImage lockFocus];
[self drawRect:imageBounds];
[anImage unlockFocus];
NSPoint p = [self convertPoint:down fromView:nil];
p.x = p.x - size.width / 2.0;
p.y = p.y - size.height / 2.0;
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSDragPboard];
[fillColor writeToPasteboard:pb];
[self dragImage:anImage at:p offset:NSMakeSize(0,0) event:mouseDownEvent pasteboard:pb source:self slideBack:YES];
[anImage release];
}
warning states that "self" (which is my NSView subclass) may not respond to NSPasteBoard?? it will accept "fillColor" which is my NSColor, but it still doesn't copy it to the pasteboard...