NSDraggingSource Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.7 and later.
Companion guide
Declared in
NSDragging.h
Related sample code

Overview

The NSDraggingSource protocol declares methods that are implemented by the source object in a dragging session.

In OS X v10.7 and later NSDraggingSource is now a formal protocol and has an updated interface. The OS X v10.6 behavior has been retained, but will be dropped in a future version of the operating system. The methods that are to be deprecated are marked as such.

Tasks

Dragging Session Operation

Dragging Session Locations

Dragging Session Modifier Keys

Dragging Options

Responding to Messages During a Dragging Session

Instance Methods

draggingSession:endedAtPoint:operation:

Invoked when the dragging session has completed.

- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation
Parameters
session

The dragging session.

screenPoint

The point where the drag ended, in screen coordinates.

operation

The drag operation. See NSDragOperation for drag operation types.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSDragging.h

draggingSession:movedToPoint:

Invoked when the drag moves on the screen.

- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint
Parameters
session

The dragging session.

screenPoint

The point where the drag moved to, in screen coordinates.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSDragging.h

draggingSession:sourceOperationMaskForDraggingContext:

Declares the types of operations the source allows to be performed. (required)

- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
Parameters
session

The dragging session.

context

The dragging context. See NSDraggingContext for the supported values.

Return Value

The appropriate dragging operation as defined in

Discussion

In the future Apple may provide more specific "within" values in the future. To account for this, for unrecognized localities, return the operation mask for the most specific context that you are concerned with. The following code is an example of how to implement this functionality:

    switch(context) {
        case NSDraggingContextOutsideApplication:
            return ...
            break;
 
        case NSDraggingContextWithinApplication:
        default:
            return ...
            break;
    }
Availability
  • Available in OS X v10.7 and later.
Declared In
NSDragging.h

draggingSession:willBeginAtPoint:

Invoked when the drag will begin.

- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint
Parameters
session

The dragging session.

screenPoint

The point where the drag will begin, in screen coordinates.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSDragging.h

ignoreModifierKeysForDraggingSession:

Returns whether the modifier keys will be ignored for this dragging session.

- (BOOL)ignoreModifierKeysForDraggingSession:(NSDraggingSession *)session
Parameters
session

The dragging session.

Return Value

YES if the modifier keys will be ignored, NO otherwise.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSDragging.h