• 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: Copy-dragging in an NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy-dragging in an NSTableView


  • Subject: Re: Copy-dragging in an NSTableView
  • From: Alastair Houghton <email@hidden>
  • Date: Thu, 9 Aug 2007 23:16:49 +0100

On 8 Aug 2007, at 17:01, Andrew Merenbach wrote:

I have overridden the following method in my table view:

- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
{
return flag ? NSDragOperationMove : NSDragOperationCopy | NSDragOperationCopy;
}

Your problem is operator precedence. The precedence of "?:" is lower than the precedence of "|", so the expression above evaluates the same as


  return flag ? NSDragOperationMove : NSDragOperationCopy;

You could fix it by putting in some brackets, or by moving the "| NSDragOperationCopy" part just before the ":".

If you need a table of operator precedence (and I think *everyone* needs a table of operator precedence :-); sticking in pointless brackets just doesn't cut the mustard, in my opinion), I made myself a nice one back in 2003 (based on the C99 spec) and stuck it up on my site. Here's a link:

  <http://alastairs-place.net/2003/08/c_operator_prec>

I have that on the wall in front of me, so I can refer to it quickly when I need to.

(Also, if you're targeting 10.4 or later, NSTableView has a - setDraggingSourceOperationMask:forLocal: method that you can call to tell it what to return, which saves subclassing if you have no other reason to do it.)

Kind regards,

Alastair.

--
http://alastairs-place.net




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Copy-dragging in an NSTableView (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: NSTableView and keyPath
  • Next by Date: Re: [FIXED] calling scrollPoint: on table view from separate thread locks up app
  • Previous by thread: Re: Copy-dragging in an NSTableView
  • Next by thread: resizing NSSegmentedControl automatically
  • Index(es):
    • Date
    • Thread