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

Preventing a drag in draggingSourceOperationMaskForLocal: not working


  • Subject: Preventing a drag in draggingSourceOperationMaskForLocal: not working
  • From: "Jeremy Higgs" <email@hidden>
  • Date: Fri, 22 Sep 2006 15:34:28 +1000

Hi everyone,

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.

Has anyone successfully prevented drags from occurring in this manner? I
thought about doing it in the delegate, but AFAIK it's a bit harder to get
what column the mouse is in (and it's not event-driven).

Any tips would be greatly appreciated!

Thanks,

Jeremy
_______________________________________________
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: Corbin Dunn <email@hidden>
  • Prev by Date: Re: Deletes Objects On Remove
  • Next by Date: Cover flow view in Itunes 7.
  • Previous by thread: Re: NSPopUpButton in a NSView in a NSCell of a NSTableView Solved
  • Next by thread: Re: Preventing a drag in draggingSourceOperationMaskForLocal: not working
  • Index(es):
    • Date
    • Thread