// 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);
}
}