[Previous] [Protocol List] [Next]

NSDraggingInfo


Declared in: AppKit/NSDragging.h


Protocol Description


The NSDraggingInfo protocol declares methods that supply information about a dragging session (see the NSDraggingDestination protocol for definitions of dragging terms). NSDraggingInfo methods are designed to be invoked from within a class's implementation of NSDraggingDestination informal protocol methods. The Application Kit automatically passes an object that conforms to the NSDraggingInfo protocol as the argument to each of the methods defined by NSDraggingDestination. NSDraggingInfo messages should be sent to this object; you never need to create a class that implements the NSDraggingInfo protocol.

Method Types


Dragging-session information
- draggingSource
- draggingSourceOperationMask
- draggingDestinationWindow
- draggingPasteboard
- draggingSequenceNumber
- draggingLocation
Image information
- draggedImage
- draggedImageLocation
Sliding the image
- slideDraggedImageTo:


Protocol Methods



draggedImage

- (NSImage *)draggedImage

Returns the image being dragged. This image object visually represents the data put on the pasteboard during the drag operation; however, it is the pasteboard data and not this image that are ultimately utilized in the dragging operation.

See Also: - draggedImageLocation



draggedImageLocation

- (NSPoint)draggedImageLocation

Returns the current location of the dragged image's origin in the base coordinate system of the destination object's window. The image moves along with the mouse pointer (the position of which is given by draggingLocation) but may be positioned at some offset.

See Also: - draggedImage



draggingDestinationWindow

- (NSWindow *)draggingDestinationWindow

Returns the destination window for the dragging operation. Either this window is the destination itself, or it contains the view object that is the destination.

draggingLocation

- (NSPoint)draggingLocation

Returns the current location of the mouse pointer in the base coordinate system of the destination object's window.

See Also: - draggedImageLocation



draggingPasteboard

- (NSPasteboard *)draggingPasteboard

Returns the pasteboard object that holds the data being dragged. The dragging operation that is ultimately performed utilizes this pasteboard data and not the image returned by the draggedImage method.

draggingSequenceNumber

- (int)draggingSequenceNumber

Returns a number that uniquely identifies the dragging session.

draggingSource

- (id)draggingSource

Returns the source, or owner, of the dragged data or nil if the source isn't in the same application as the destination. The dragging source implements methods from the NSDraggingSource informal protocol.

draggingSourceOperationMask

- (unsigned int)draggingSourceOperationMask

Returns the dragging operation mask declared by the dragging source (through its draggingSourceOperationMaskForLocal: method). If the source permits dragging operations, the elements in the mask will be one or more of the following, combined using the C bitwise OR operator:
OptionMeaning
NSDragOperationCopyThe data represented by the image can be copied.
NSDragOperationLinkThe data can be shared.
NSDragOperationGenericThe operation can be defined by the destination.
NSDragOperationPrivateThe operation is negotiated privately between the source and the destination.
NSDragOperationAllCombines all the above.

If the source does not permit any dragging operations, this method should return NSDragOperationNone.

If the user is holding down a modifier key during the dragging session and the source doesn't prohibit modifier keys from affecting the drag operation (through its ignoreModifierKeysWhileDragging method), then the operating system combines the dragging operation value that corresponds to the modifier key (see the descriptions below) with the source's mask using the C bitwise AND operator.

On Mach the modifier keys are associated with the dragging operation options shown below:


Modifier KeyDragging Option
ControlNSDragOperationLink
AlternateNSDragOperationCopy
CommandNSDragOperationGeneric

On Windows the modifier keys are associated with the following dragging operation options:


Modifier KeyDragging Option
ControlNSDragOperationCopy
Shift-ControlNSDragOperationLink
AlternateNSDragOperationCopy



slideDraggedImageTo:

- (void)slideDraggedImageTo:(NSPoint)aPoint

Slides the image to aPoint, a specified location in the screen coordinate system. This method can be used to snap the image down to a particular location. It should only be invoked from within the destination's implementation of prepareForDragOperation:-in other words, after the user has released the image but before it's removed from the screen.


[Previous] [Next]