DragEvent.effect

Overview | Methods | Fields | This Package | All Packages

DragEvent.effect

Specifies which drag-and-drop operations are allowed; can be set to specify the current drag-and-drop operation.

Syntax

public int effect;

Remarks

The value of the effect field passed with an event initially represents the drag-and-drop effects allowed for the control. The value passed is the result of applying the bitwise OR operation (|) to constants defined in the DragDropEffect class. You can use the effect field to store the current drag-and-drop effect. This information can be used to optimize a drag-and-drop operation, as shown in the following code:

private int effect = 0;

private void testControl_dragEnter(Object sender, DragEvent e) {
    // Check if the COPY effect is allowed.
    if ((e.effect & DragDropEffect.COPY) != 0) {
        // If so, set the current effect to COPY.
        e.effect = DragDropEffect.COPY;
    }
    // Store the current effect. This can then be used to optimize the dragOver event handler.
    effect = e.effect;
}

private void testControl_dragOver(Object sender, DragEvent e) {
    // Set the effect for the dragOver event to the current effect.
    e.effect = effect;
}