Package com.ms.object.dragdrop
 In this topic

*Methods

 

Packages
  PreviousThis PackageNext
Package com.ms.object.dragdrop   Previous This
Package
Next

 


Class DragHelper

public abstract class DragHelper implements DragHandler
{
  // Methods
  public void dragEnter(DragSession session);
  public void dragLeave();
  public int dragOver(DragSession session, int x, int y);
  public void drop(DragSession session, int x, int y);
  protected abstract Object findDragObject(DragSession session, int
        x, int y);
  protected abstract DragHandler getDragHandler(
        DragSession session, Object object);
  protected void trackDragStatus(DragSession session,
        Object object, int effect);
}

This class provides a default implementation for a dragdrop protocol involving a set of objects that the system does not support. For instance, if you are designing a tree control that is not composed of system components, you could use this class (along with the DragProxy class) to help implement the enter, continue, leave, and drop behaviors over the subelements in your tree.

Typically, you would extend the DragHelper class, providing hit-testing code to implement the findDragObject and getDragHandler methods.

When a drag method is called on a class that extends DragHelper, the drag method calls the findDragObject method to hit-test the coordinates in the drag method. The derived class returns an Object that represents the hit result.

If the Object has changed since the last hit-test, the drag helper then calls the getDragHandler method to obtain a DragHandler for the new hit Object. In addition, the derived class can override the trackDragStatus method to implement highlighting or some other form of feedback.

Methods

dragEnter

public void dragEnter(DragSession session);

Notifies the recipient when a source object enters the space that is defined by a container, window, or object.

Return Value:

No return value.

ParameterDescription
session The DragSession object that represents the current drag operation.

dragLeave

public void dragLeave();

Notifies the recipient when a source object exits the space that is defined by a container, window, or object.

Return Value:

No return value.

dragOver

public int dragOver(DragSession session, int x, int y);

Notifies the recipient when a source object continues through the space that is defined by a container, window, or object.

Return Value:

Returns one or more of the following values:
NONE, COPY, MOVE, or LINK.

ParameterDescription
session The DragSession object that represents the current drag operation.
x The x coordinate of the current cursor position.
y The y coordinate of the current cursor position.

drop

public void drop(DragSession session, int x, int y);

Notifies the recipient when a source object is dropped at a new location.

Return Value:

No return value.

ParameterDescription
session The DragSession object that represents the current drag operation.
x The x coordinate of the current cursor position.
y The y coordinate of the current cursor position.

findDragObject

protected abstract Object findDragObject(DragSession session, 
        int x, int y);

Provides a hit-test of the coordinates in the drag method.

Return Value:

Returns the object that represents the hit result.

ParameterDescription
session The DragSession object that represents the current drag operation.
x The x coordinate to hit-test.
y The y coordinate to hit-test.

getDragHandler

protected abstract DragHandler getDragHandler(DragSession session,
        Object object);

Retrieves the DragHandler object for the specified drag session.

Return Value:

Returns a DragHandler for the drag-and-drop operation.

ParameterDescription
session The DragSession object that represents the current drag operation.
object The object returned by the findDragObject method.

trackDragStatus

protected void trackDragStatus(DragSession session, Object object,
        int effect);

This method is not currently implemented. It is called by the dragEnter, dragOver, and dragLeave methods to track the status of the current drag operation.

Return Value:

No return value.

ParameterDescription
session The DragSession object that represents the current drag operation.
object The object that is being dragged.
effect The value that indicates the drag status.

upnrm.gif