Contents

draggingSession(_:sourceOperationMaskFor:)

Declares the types of operations the source allows to be performed.

Declaration

@MainActor func draggingSession(_ session: NSDraggingSession, sourceOperationMaskFor context: NSDraggingContext) -> NSDragOperation

Parameters

  • session:

    The dragging session.

  • context:

    The dragging context. See Nsdraggingcontext for the supported values.

Return Value

A dragging operation you specify.

Discussion

To account for unexpected contexts, set a default case for the most specific context your app handles. The following code shows an example that handles different dragging contexts and includes a default case.

    switch(context) {
        case NSDraggingContextOutsideApplication:
            return NSDragOperationCopy;
 
        case NSDraggingContextWithinApplication:
        default:
            return NSDragOperationCopy | NSDragOperationMove;
    }