1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.dnd;
16 import org.eclipse.swt.events.*;
17 import org.eclipse.swt.graphics.*;
20 * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
22 * @see DragSourceListener
23 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
25 public class DragSourceEvent extends TypedEvent {
27 * The operation that was performed.
32 * @see DND#DROP_TARGET_MOVE
37 * In dragStart, the doit field determines if the drag and drop operation
38 * should proceed; in dragFinished, the doit field indicates whether
39 * the operation was performed successfully.
42 * <p>Flag to determine if the drag and drop operation should proceed.
43 * The application can set this value to false to prevent the drag from starting.
44 * Set to true by default.</p>
45 * <p>In dragSetData:</p>
46 * <p>This will be set to true when the call to dragSetData is made. Set it to
47 * false to cancel the drag.</p>
48 * <p>In dragFinished:</p>
49 * <p>Flag to indicate if the operation was performed successfully.
50 * True if the operation was performed successfully.</p>
55 * In dragStart, the x coordinate (relative to the control) of the
56 * position the mouse went down to start the drag.
62 * In dragStart, the y coordinate (relative to the control) of the
63 * position the mouse went down to start the drag.
70 * The type of data requested.
71 * Data provided in the data field must be of the same type.
73 public TransferData dataType;
76 * The drag source image to be displayed during the drag.
77 * <p>A value of null indicates that no drag image will be displayed.</p>
78 * <p>The default value is null.</p>
85 * In dragStart, the x offset (relative to the image) where the drag source image will be displayed.
91 * In dragStart, the y offset (relative to the image) where the drag source image will be displayed.
97 static final long serialVersionUID = 3257002142513770808L;
100 * Constructs a new instance of this class based on the
101 * information in the given untyped event.
103 * @param e the untyped event containing the information
105 public DragSourceEvent(DNDEvent e) {
108 this.detail = e.detail;
110 this.dataType = e.dataType;
113 this.image = e.image;
114 this.offsetX = e.offsetX;
115 this.offsetY = e.offsetY;
117 void updateEvent(DNDEvent e) {
118 e.widget = this.widget;
121 e.detail = this.detail;
123 e.dataType = this.dataType;
126 e.image = this.image;
127 e.offsetX = this.offsetX;
128 e.offsetY = this.offsetY;
131 * Returns a string containing a concise, human-readable
132 * description of the receiver.
134 * @return a string representation of the event
137 public String toString() {
138 String string = super.toString ();
139 return string.substring (0, string.length() - 1) // remove trailing '}'
140 + " operation=" + detail
141 + " type=" + (dataType != null ? dataType.type : 0)