Hi all,
I am doing drag and drop with NSView.
In the object to be dragged, which is subclass of NSView, I implemented mouseDown: method as follows:
@try {
NSPoint location;
NSSize size ;
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"CameraIconContainer"];
location.x = ([self bounds].size.width - size.width)/2 - 21.0;
location.y = ([self bounds].size.height - size.height)/2 - 7.0;
NSLog(@"mouseDown: location- (%f, %f)",location.x,location.y);
NSDictionary *iconViewDict = [[NSDictionary alloc] initWithObjectsAndKeys:[cameraNo stringValue],@"cameraNo",nil];
NSLog(@"iconViewDict - %@",iconViewDict);
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:iconViewDict];
[pb declareTypes:[NSArray arrayWithObject:IconDragDataType] owner:self];
[pb setData:data forType:IconDragDataType];
[self dragImage:[NSImage imageNamed:@"camera_icon.png"] at:location offset:NSZeroSize event:e pasteboard:pb source:self slideBack:YES];
}
@catch (NSException * e) {
NSLog(@"CameraIconView (-mouseDown:), error - %@",e);
}
Most of the time it is working fine but problem is- sometimes it is raising this
exception:Invalid parameter not satisfying: theWriteStream != NULL
in the mouseDown: method, because of it the dragged image continuously appears over screen, which does not disappear even if some other window is selected.
Can anyone suggest me why is it occurring and how can I resolve it?
Thanks,
Miraaj