• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSBrowser/NSMatrix as drag-and-drop source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • [SOLVED] Re: NSBrowser/NSMatrix as drag-and-drop source
      • From: Kevin Dorne <email@hidden>
    • Re: NSBrowser/NSMatrix as drag-and-drop source
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Accessing NSTableView cell information
  • Next by Date: Re: NSBrowser/NSMatrix as drag-and-drop source
  • Previous by thread: Re: Accessing NSTableView cell information
  • Next by thread: Re: NSBrowser/NSMatrix as drag-and-drop source
  • Index(es):
    • Date
    • Thread