NSBrowser/NSMatrix as drag-and-drop source
NSBrowser/NSMatrix as drag-and-drop source
- Subject: NSBrowser/NSMatrix as drag-and-drop source
- From: Kevin Dorne <email@hidden>
- Date: Thu, 26 May 2005 14:47:32 -0700
Hi all,
I'm trying to use an NSBrowser as a drag and drop source, but I'm running into some difficulties.
I've subclassed NSMatrix and told my NSBrowser to use that subclass. The subclass (call it MyMatrix) doesn't seem to handle mouse down/dragged events properly. MyMatrix is an NSListModeMatrix, and it allowsEmptySelection. The NSBrowser allowsBranchSelection, allowsEmptySelection, and allowsMultipleSelection.
Following an example posted December 2003, I've added mouseDown and mouseDragged methods to MyMatrix. The issue is that if I have the mouseDown method as below, I can't select multiple cells, but dragging works. If I just have the mouseDragged method, I can select multiple cells, but dragging doesn't work.
Is the code below correct, or am I going about this wrong?
Cheers,
-k
- (void)mouseDown:(NSEvent *)event
{
int row, col;
if ([self getRow: &row column: &col
forPoint:[self convertPoint:[event locationInWindow]
fromView: nil]]) {
[self selectCellAtRow: row column: col];
[self sendAction];
}
}
-(void)mouseDragged:(NSEvent *)event
{
NSPasteboard *pboard;
NSImage *dragImage;
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
/* snip */
}
-(BOOL)acceptsFirstResponder
{
return YES;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden