Re: NSTableView Drag & Drop again...
Re: NSTableView Drag & Drop again...
- Subject: Re: NSTableView Drag & Drop again...
- From: Tom Waters <email@hidden>
- Date: Fri, 6 Jul 2001 16:52:38 -0700
I can't help you with the problem, but I can at least commiserate with
you...
Apparently, the NSScrollView mechanism believes that the contentView
inside of it is always drawn without regard to the visibleRect. That is
to say that it believes that it should scroll up the bitmap image of
what you've drawn, and then call drawRect in your view, with just the
small rectangle exposed by the scroll. If you are painting the
rectangle around the visibleRect to show that the entire tableView is
the drop target, as it appears is the HID convention, then NSScrollView
will leave screen garbage.
If you subclass and overload drawRect to do the right thing, NSView will
cease to use the copy area and call drawRect on your entire visibleRect
each time it scrolls, which is unfortunately WAY too slow to be useful.
My thought is, NSScrollView should have a delegate message which asks
what areas of the contentView can be copied, and then the delegate can
leave out the few scanlines at the edge that would be wrong.
Something like this would do...
- (NSRect)scrollView:(NSScrollView *)sv willScrollRect:(NSRect *)rect
by:(NSSize *)scroll;
The NSScrollView would call drawRect on your contentView with difference
between [visibleRect bounds] and the rect your returned above from
scrollView:willScrollRect:by:
If this was implemented you could do the following in a category on
NSTableView to fix the problem (assuming that the border is 2 pixels
wide... it might be more).
- (NSRect)scrollView:(NSScrollView *)sv willScrollRect:(NSRect *)rect
by:(NSSize *)scroll
{
if (scroll.width != 0) {
rect.width -= 2;
if (scroll.width > 0)
rect.origin.x += 2;
}
if (scroll.height != 0) {
rect.height -= 2;
if (scroll.height > 0)
rect.origin.y += 2;
}
return rect;
}
So, the short answer is, you're right, it sucks, and I don't know what
the workaround is.
On Friday, July 6, 2001, at 10:59 AM, Stiphane Sudre wrote:
Is it officialy supported to specify -1 as the drop row with a
NSTableViewDropOn to get the whole tableview selected for a drop ?
Example:
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id
<NSDraggingInfo>)info proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)op
{
NSData * tData;
tData=[[info draggingPasteboard] dataForType:NSStringPboardType];
if (tData!=nil)
{
[tv setDropRow:-1 dropOperation:NSTableViewDropOn];
return NSDragOperationCopy;
}
return NSDragOperationNone;
}
Because when I do this and scroll in the NSTableView, there are
cosmetic bugs: lots of horizontal black line (bad clipping ?)
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev