• 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
Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working


  • Subject: Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working
  • From: Corbin Dunn <email@hidden>
  • Date: Fri, 22 Sep 2006 16:11:53 -0700


I'm trying to implement horizontal dragging in an NSTableView cell (the same
sort of functionality iTunes provides when setting song ratings), but am
having some problems. I have overridden the
draggingSourceOperationMaskForLocal: method in an NSTableView subclass
(which has been set as the custom class in the nib) to do the following:


- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
{
// If we're in one of the "no-drag" columns (set in mouseDown:) don't
allow a drag to occur
if (!_horizontalMotionCanBeginDrag)
{
return NSDragOperationNone;
}


   return [super draggingSourceOperationMaskForLocal:isLocal];
}

The value for _horizontalMotionCanBeginDrag is set in mouseDown:, by
checking if the mouse cursor is in one of the table columns we want to
disable drags in:

- (void)mouseDown:(NSEvent *)event
{
BOOL mouseInNoDragColumns = ([[[self mouseTableColumnForEvent:event]
identifier] isEqualToString:@"columnA"] ||
[[[self mouseTableColumnForEvent:event]
identifier] isEqualToString:@"columnB"]);


   // If we're in a "no-drag" column, flag it
   _horizontalMotionCanBeginDrag = !mouseInNoDragColumns;

   [super mouseDown:event];
}

---

When I try and perform a "horizontal" drag in those particular cells, I can
see NSDragOperationNone being returned from the
draggingSourceOperationMaskForLocal: method. Despite this, a drag image is
still produced (and a drag occurs, as writeRows: in the delegate is called).
According to the docs, this is what I should be doing to prevent a drag from
this row.

That's too late to do it. From a table, do this in your delegate:

- (BOOL)tableView:(NSYourTableView *)tableView writeRowsWithIndexes: (NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard {
if ([tableView canDrag]) { ... stuff } else { return NO; }
}


set the "canDrag" in the subclass of your tableview (NSYourTableView) with mouseDown: code similar to what you have.

I understand this is difficult to do and something like this will be made easier to do in the future.

thanks,
--corbin

_______________________________________________
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:
    • Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working
      • From: "Jeremy Higgs" <email@hidden>
References: 
 >Preventing a drag in draggingSourceOperationMaskForLocal: not working (From: "Jeremy Higgs" <email@hidden>)

  • Prev by Date: Cocoa dialog in CarbonLib App
  • Next by Date: Re: How much does NSObject's bind:toObject:withKeyPath:options: do?
  • Previous by thread: Preventing a drag in draggingSourceOperationMaskForLocal: not working
  • Next by thread: Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working
  • Index(es):
    • Date
    • Thread