(informal protocol)
Framework | /System/Library/Frameworks/AppKit.framework |
Companion guide | |
Declared in | NSDragging.h |
The NSDraggingDestination
informal protocol declares methods that the destination object (or recipient) of a dragged image must implement. The destination automatically receives NSDraggingDestination
messages for pasteboard data types it has registered for as an image enters, moves around inside, and then exits or is released within the destination’s boundaries.
– draggingEntered:
– wantsPeriodicDraggingUpdates
– draggingUpdated:
– draggingEnded:
– draggingExited:
Invoked when the dragging operation is complete, signaling the receiver to perform any necessary clean-up.
- (void)concludeDragOperation:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
For this method to be invoked, the previous performDragOperation:
must have returned YES
. The destination implements this method to perform any tidying up that it needs to do, such as updating its visual representation now that it has incorporated the dragged data. This message is the last message sent from sender to the destination during a dragging session.
NSDragging.h
Implement this method to be notified when a drag operation ends in some other destination.
- (void)draggingEnded:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
This method might be used by a destination doing auto-expansion in order to collapse any auto-expands. This method has not yet been implemented.
NSDragging.h
Invoked when the dragged image enters destination bounds or frame; delegate returns dragging operation to perform.
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
One (and only one) of the dragging operation constants described in “Constants” in the NSDraggingInfo
reference. The default return value (if this method is not implemented by the destination) is the value returned by the previous draggingEntered:
message.
Invoked when a dragged image enters the destination but only if the destination has registered for the pasteboard data type involved in the drag operation. Specifically, this method is invoked when the mouse pointer enters the destination’s bounds rectangle (if it is a view object) or its frame rectangle (if it is a window object).
This method must return a value that indicates which dragging operation the destination will perform when the image is released. In deciding which dragging operation to return, the method should evaluate the overlap between both the dragging operations allowed by the source (obtained from sender with the draggingSourceOperationMask
method) and the dragging operations and pasteboard data types the destination itself supports.
If none of the operations is appropriate, this method should return NSDragOperationNone
(this is the default response if the method is not implemented by the destination). A destination will still receive draggingUpdated:
and draggingExited:
even if NSDragOperationNone
is returned by this method.
NSDragging.h
Invoked when the dragged image exits the destination’s bounds rectangle (in the case of a view object) or its frame rectangle (in the case of a window object).
- (void)draggingExited:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
NSDragging.h
Invoked periodically as the image is held within the destination area, allowing modification of the dragging operation or mouse-pointer position.
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
One (and only one) of the dragging operation constants described in “Constants” in the NSDraggingInfo
reference. The default return value (if this method is not implemented by the destination) is the value returned by the previous draggingEntered:
message.
For this to be invoked, the destination must have registered for the pasteboard data type involved in the drag operation. The messages continue until the image is either released or dragged out of the window or view.
This method provides the destination with an opportunity to modify the dragging operation depending on the position of the mouse pointer inside of the destination view or window object. For example, you may have several graphics or areas of text contained within the same view and wish to tailor the dragging operation, or to ignore the drag event completely, depending upon which object is underneath the mouse pointer at the time when the user releases the dragged image and the performDragOperation:
method is invoked.
You typically examine the contents of the pasteboard in the draggingEntered:
method, where this examination is performed only once, rather than in the draggingUpdated:
method, which is invoked multiple times.
Only one destination at a time receives a sequence of draggingUpdated:
messages. If the mouse pointer is within the bounds of two overlapping views that are both valid destinations, the uppermost view receives these messages until the image is either released or dragged out.
NSDragging.h
Invoked after the released image has been removed from the screen, signaling the receiver to import the pasteboard data.
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
If the destination accepts the data, it returns YES
; otherwise it returns NO
. The default is to return NO
.
For this method to be invoked, the previous prepareForDragOperation:
message must have returned YES
. The destination should implement this method to do the real work of importing the pasteboard data represented by the image.
NSDragging.h
Invoked when the image is released, allowing the receiver to agree to or refuse drag operation.
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender
The object sending the message; use it to get details about the dragging operation.
YES
if the receiver agrees to perform the drag operation and NO
if not.
This method is invoked only if the most recent draggingEntered:
or draggingUpdated:
message returned an acceptable drag-operation value.
NSDragging.h
Asks the destination object whether it wants to receive periodic draggingUpdated:
messages.
- (BOOL)wantsPeriodicDraggingUpdates
YES
if the destination wants to receive periodic draggingUpdated:
messages, NO
otherwise.
If the destination returns NO
, these messages are sent only when the mouse moves or a modifier flag changes. Otherwise the destination gets the default behavior, where it receives periodic dragging-updated messages even if nothing changes.
NSDragging.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-01)