diff options
author | Lakshmi Shanmugam <lshanmugam> | 2010-08-11 18:11:47 +0000 |
---|---|---|
committer | Lakshmi Shanmugam <lshanmugam> | 2010-08-11 18:11:47 +0000 |
commit | bcb8c5d7f663003ad3fc43bf1aa4aaec5bd3bdaf (patch) | |
tree | 10eaea321be7ca857f388d1b8f99c39dd2220fc6 /bundles/org.eclipse.swt | |
parent | 80ca8951224b622855cfac7f663b9b962d66aaed (diff) | |
download | eclipse.platform.swt-bcb8c5d7f663003ad3fc43bf1aa4aaec5bd3bdaf.tar.gz eclipse.platform.swt-bcb8c5d7f663003ad3fc43bf1aa4aaec5bd3bdaf.tar.xz eclipse.platform.swt-bcb8c5d7f663003ad3fc43bf1aa4aaec5bd3bdaf.zip |
Bug 243529 - [DND] [Mac] Erratic DND behaviour on Mac OS X
Diffstat (limited to 'bundles/org.eclipse.swt')
4 files changed, 42 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java index f1f8ff4544..7aa900bde6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java @@ -110,6 +110,7 @@ public class DragSource extends Widget { DragSourceEffect dragEffect; static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ + static final String DRAG_STARTED = "org.eclipse.swt.internal.dragStarted"; //$NON-NLS-1$ static Callback DragSendDataProc; static { @@ -327,7 +328,9 @@ void drag(Event dragEvent) { theEvent.what = (short)OS.osEvt; theEvent.where_h = pt.h; theEvent.where_v = pt.v; + control.setData(DRAG_STARTED, new Object()); int result = OS.TrackDrag(theDrag[0], theEvent, theRegion); + control.setData(DRAG_STARTED, null); int operation = DND.DROP_NONE; if (result == OS.noErr) { int[] outAction = new int[1]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java index f0f5033170..b01f7449c7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java @@ -79,6 +79,7 @@ public abstract class Control extends Widget implements Drawable { Accessible accessible; static final String RESET_VISIBLE_REGION = "org.eclipse.swt.internal.resetVisibleRegion"; //$NON-NLS-1$ + static final String DRAG_STARTED = "org.eclipse.swt.internal.dragStarted"; //$NON-NLS-1$ Control () { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java index 892c0b4828..d4b58327e3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java @@ -2153,6 +2153,25 @@ int itemNotificationProc (int browser, int id, int message) { } return OS.noErr; } + + /* + * The items in the databrowser lose their selection when we + * drag them (when we call OS.TrackDrag() in DragSource.drag()). + * We get kDataBrowserItemDeselected notification message + * for each of the items. The workaround is to select the + * deselected items in this case. DRAG_STARTED is set/unset + * before/after the call to OS.TrackDrag(). + * + * This doesn't happen for Table with SWT.SINGLE style because + * we have set the OS.kDataBrowserNeverEmptySelectionSet flag. + */ + if (message == OS.kDataBrowserItemDeselected && (style & SWT.MULTI) != 0 && getData(DRAG_STARTED) != null) { + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 1, new int[] {id}, OS.kDataBrowserItemsAdd); + ignoreSelect = false; + return OS.noErr; + } + int index = getIndex (id); if (!(0 <= index && index < items.length)) return OS.noErr; switch (message) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java index 25f7d643ec..b499f4eb0f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java @@ -2312,6 +2312,25 @@ int itemNotificationProc (int browser, int id, int message) { } return OS.noErr; } + + /* + * The items in the databrowser lose their selection when we + * drag them (when we call OS.TrackDrag() in DragSource.drag()). + * We get kDataBrowserItemDeselected notification message + * for each of the items. The workaround is to select the + * deselected items in this case. DRAG_STARTED is set/unset + * before/after the call to OS.TrackDrag(). + * + * This doesn't happen for Tree with SWT.SINGLE style because + * we have set the OS.kDataBrowserNeverEmptySelectionSet flag. + */ + if (message == OS.kDataBrowserItemDeselected && (style & SWT.MULTI) != 0 && getData(DRAG_STARTED) != null) { + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 1, new int[] {id}, OS.kDataBrowserItemsAdd); + ignoreSelect = false; + return OS.noErr; + } + switch (message) { case OS.kDataBrowserItemSelected: savedAnchor = 0; |