(informal protocol)
Framework | /System/Library/Frameworks/AppKit.framework |
Companion guide | |
Declared in | NSDragging.h |
The NSDraggingSource
informal protocol declares methods that are implemented by the source object in a dragging session. The dragging source is specified as an argument to the dragImage:at:offset:event:pasteboard:source:slideBack:
message, sent to a window or view object to initiate the dragging session.
Of the methods declared below, only draggingSourceOperationMaskForLocal:
must be implemented. The other methods are invoked only if the dragging source implements them. All methods are invoked automatically during a dragging session—you never send an NSDraggingSource
message directly to an object.
– draggedImage:beganAt:
– draggedImage:movedTo:
– draggedImage:endedAt:deposited:
– draggedImage:endedAt:operation:
– namesOfPromisedFilesDroppedAtDestination:
Gives the source object an opportunity to respond to the initiation of a dragging session.
- (void)draggedImage:(NSImage *)anImage beganAt:(NSPoint)aPoint
The image of the dragged item.
The origin of the image in screen coordinates.
This method is invoked when anImage is displayed but before it starts following the mouse. For example, you might choose to have the source give a visual indication to the user that data is being dragged from the source.
– convertScreenToBase:
(NSWindow)– convertBaseToScreen:
(NSWindow)– convertPoint:fromView:
(NSView)– convertPoint:toView:
(NSView)NSDragging.h
Invoked after the dragging destination has been given a chance to operate on the data represented by the image, (Deprecated)
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint deposited:(BOOL)flag
This method has been deprecated. Use draggedImage:endedAt:operation:
instead.
NSDragging.h
Invoked after the dragging destination has been given a chance to operate on the data represented by the image,
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
The dragged image.
The point locating the image’s origin in the screen coordinate system when it was released.
An integer constant that indicates the operation performed by the destination.
This method is invoked after the dragged image (anImage) has been released and the dragging destination has been given a chance to operate on the data it represents. This method provides the source object with an opportunity to respond to either a successful or a failed dragging session. For example, if you are moving data from one location to another, you could use this method to make the source data disappear from its previous location, if the dragging session is successful, or reset itself to its previous state, in the event of a failure.
NSDragging.h
Informs the dragging source when a dragged image moves to a new screen coordinate.
- (void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint
The dragged image.
The point specifying the new location of the image in screen coordinates.
This message is similar to the dragging destination being sent draggingUpdated:
messages.
NSDragging.h
Returns an integer bit mask indicating the types of dragging operations the source object will allow to be performed on the dragged image's data.
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
YES
indicates that the candidate destination object (the window or view over which the dragged image is currently poised) is in the same application as the source, while a NO
value indicates that the destination object is in a different application.
This method is the only NSDraggingSource
method that must be implemented by the source object. It should return a mask, built by combining the allowed dragging operations listed in the “Constants” section of the NSDraggingInfo
protocol reference, using the C bitwise OR operator. If the source does not permit any dragging operations, it should return NSDragOperationNone
.
NSDragging.h
Sets whether the use of modifier keys should have an effect on the type of operation performed.
- (BOOL)ignoreModifierKeysWhileDragging
If this method is not implemented or returns NO
, the user can tailor the drag operation by holding down a modifier key during the drag. The dragging option that corresponds to the modifier key is combined with the source’s mask (as set with the draggingSourceOperationMaskForLocal:
method) using the C bitwise AND operator. See the description for the draggingSourceOperationMask
method in the NSDraggingInfo protocol specification for more information about dragging masks and modifier keys.
NSDragging.h
Returns the names of the files that the receiver promises to create at a specified location.
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
A URL object that identifies the location at which the promised files will be created.
An array of the names of files (not full paths) that the receiver promises to create at dropDestination
.
This method is invoked when the drop has been accepted by the destination and the destination, in the case of another Cocoa application, invokes the NSDraggingInfo method namesOfPromisedFilesDroppedAtDestination:
. For long operations, you can cache dropDestination and defer the creation of the files until the draggedImage:endedAt:operation:
method to avoid blocking the destination application.
NSDragging.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-01)