For the More Curious: Operation Mask

For some apps, the negotiation of what operation will occur when the user drops can be quite complicated. After all, the source advertises its willingness to participate in some kinds of operations through draggingSession(_:sourceOperationMaskForDraggingContext:). The user may also indicate preferences by holding down the Control, Option, or Command key. It is the job of the destination to determine what happens.

The dragging info object will do most of the work for you. It will get the source’s advertised operation mask and filter it, depending on what modifier keys the user holds down. To see this, implement draggingUpdated(_:) and log out the dragging info’s operation mask:

 ​ ​ ​ ​o​v​e​r​r​i​d​e​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.