Re: Dragging to table view without indicator
Re: Dragging to table view without indicator
- Subject: Re: Dragging to table view without indicator
- From: Shaun Wexler <email@hidden>
- Date: Sun, 26 Jan 2003 18:28:46 -0800
On Sunday, January 26, 2003, at 02:37 PM, Andrew Merenbach wrote:
I would like to accept various drops on my table view, but would
rather that the entire table view become outlined, rather than an
indicator bar be drawn, to signal that a drop can occur, as the
dropped data would not be inserted at the particular location
indicated by the bar. What will I need to do to make this happen?
Take care,
Andrew
Easy. You'll need to implement these three methods in your NSTableView
delegate/datasource:
- (BOOL) tableView:(NSTableView *)tableview writeRows:(NSArray *)rows
toPasteboard:(NSPasteboard *)pboard;
- (unsigned int) tableView:(NSTableView *)tableview validateDrop:(id
<NSDraggingInfo>)info proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)operation;
- (BOOL) tableView:(NSTableView *)tableview acceptDrop:(id
<NSDraggingInfo>)info row:(int)row
dropOperation:(NSTableViewDropOperation)operation;
Then, in your NSTableView subclass (you must subclass), add some code
to the methods:
BOOL _shouldDrawFocusRing = NO;
- (NSDragOperation) draggingEntered:(id <NSDraggingInfo>)sender
{
NSDragOperation operation = [super draggingEntered:sender];
// code here to decide how to handle the drag, and modify operation if
needed
_shouldDrawFocusRing = YES; // NO, if drag will not be accepted
[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
return operation;
}
- (void) draggingExited:(id <NSDraggingInfo>)sender
{
_shouldDrawFocusRing = NO;
[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
[super draggingExited:sender];
}
- (void) concludeDragOperation:(id <NSDraggingInfo>)sender
{
_shouldDrawFocusRing = NO;
[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
[super concludeDragOperation:sender];
}
- (void) drawRect:(NSRect)rect
{
[super drawRect: rect];
if (_shouldDrawFocusRing) {
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill([self bounds]);
}
}
Hope that makes it work for you.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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.