OSDN Git Service

GLE: Yet another reference to event.offsetX/Y.
authorRaphael Moll <ralf@android.com>
Sat, 13 Nov 2010 03:06:24 +0000 (19:06 -0800)
committerRaphael Moll <ralf@android.com>
Sat, 13 Nov 2010 03:06:24 +0000 (19:06 -0800)
Change-Id: I13eeb5ed05a2f62d6afeb7009d934bd60f6f5cfd

eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PaletteComposite.java

index 7bf336c..d7fdd1e 100755 (executable)
@@ -606,24 +606,29 @@ public class PaletteComposite extends Composite {
                 // mouse pointer
 
                 // TODO quick'ndirty fix. swt.dnd in 3.4 doesn't have offsetX/Y.
+                ControlPoint offset = ControlPoint.create(null, 0, 0);
                 try {
                     Field xField = event.getClass().getDeclaredField("offsetX");
                     Field yField = event.getClass().getDeclaredField("offsetY");
 
-                    xField.set(event, Integer.valueOf(mImage.getBounds().width / 2));
-                    yField.set(event, Integer.valueOf(mImage.getBounds().height / 2));
+                    int offsetX = mImage.getBounds().width / 2;
+                    int offsetY = mImage.getBounds().height / 2;
+                    xField.set(event, Integer.valueOf(offsetX));
+                    yField.set(event, Integer.valueOf(offsetY));
+
+                    // ...and record this info in the drag state object such that we can
+                    // account for it when performing the drop, since we want to place the newly
+                    // inserted object where it is currently shown, not with its top left corner
+                    // in the center where the mouse cursor was (this mostly matters for
+                    // the AbsoluteLayout).
+                    offset = ControlPoint.create(null, -offsetX, -offsetY);
+
                 } catch (SecurityException e) {
                 } catch (NoSuchFieldException e) {
                 } catch (IllegalArgumentException e) {
                 } catch (IllegalAccessException e) {
                 }
 
-                // ...and record this info in the drag state object such that we can
-                // account for it when performing the drop, since we want to place the newly
-                // inserted object where it is currently shown, not with its top left corner
-                // in the center where the mouse cursor was (this mostly matters for
-                // the AbsoluteLayout).
-                ControlPoint offset = ControlPoint.create(null, -event.offsetX, -event.offsetY);
                 GlobalCanvasDragInfo.getInstance().setImageOffset(offset);
             }
         }