Dragging inside NSTableView leaks memory?
Dragging inside NSTableView leaks memory?
- Subject: Dragging inside NSTableView leaks memory?
- From: Nikita Zhuk <email@hidden>
- Date: Sat, 4 Jan 2003 01:19:13 +0200
Hi,
I'm trying to make a very simple support for drops in my NSTableView
subclass (called fileTableView). The idea was to be able to add files
and folders into tableview as list by dropping them into table (and
of course save them internally in some array in the app). I know this
topic has been previously discussed on this list, but I couldn't
find a clear explanation about implementation of this kind simple
drop support.
However, I noticed that my implementation leaked memory (RSIZE in
top kept growing when I moved the dropped file inside tableview area
with my mouse button pressed down). Could you show me where is the
problem?
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:
NSColorPboardType, NSFilenamesPboardType, nil]];
rectPath = [[[NSBezierPath alloc] init] retain];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
NSLog(@"We're inside the tableview area");
highlight=YES;
[self drawRect:[self frame]]; // Draw the active border
if ( [[pboard types] containsObject:NSColorPboardType] )
{
if (sourceDragMask & NSDragOperationCopy)
{
return NSDragOperationCopy;
}
}
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
{
if (sourceDragMask & NSDragOperationLink)
{
// NSArray *droppedFiles = [[pboard
propertyListForType:NSFilenamesPboardType] retain];
// [self handleDroppedFolderItems: droppedFiles]; -
method coming soon
return NSDragOperationLink;
}
else if (sourceDragMask & NSDragOperationCopy)
{
return NSDragOperationCopy;
}
}
return NSDragOperationNone;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
highlight=NO;//remove highlight of the drop zone
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];//do the usual draw operation to display the image
[rectPath removeAllPoints];
[rectPath appendBezierPathWithRect:rect];
[[NSColor selectedControlColor] set];
if(highlight)
{
[rectPath setLineWidth:5.0];
[rectPath stroke];
[self setNeedsDisplay:YES];
}
else
{
[rectPath setLineWidth:0.0];
[rectPath stroke];
[self setNeedsDisplay:YES];
}
}
--
******************************
* Nikita Zhuk
* MacZ Software & Frozdesign
******************************
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.