Community
Participate
Working Groups
build 20021001 Dragging items in the resource navigator does not work. The drag icon appears, but there is no drop location feedback. NavigatorDragAdapter.dragStart checks whether the drag source actually has focus. Display.getFocusControl returns null even though the tree viewer does have focus. When I comment out this check and dragStart lets the drop operation continue the drop adapter still does not get a dragEnter event. Package view DND no longer works either. Did SWT change anything wrt. Motif DND that could have broken this?
This stopped working going from SWT build 2106 to 2107.
Between 2106 and 2107 I added the code to fix 22959 - the case where you had multiple drop targets stacked on top of one another. Reassign the bug to Platform SWT and I will investigate.
Note that getFocusControl returning null may be a separate issue or it may be the reason why the DragEnter event is not sent. DragEnter event is handled by NavigatorDropAdapter.dragEnter
SWT is behaving as expected. This is a problem in the UI code. The reason you are getting no feedback during drag over is because on drag enter you are setting the event.detail field to DND_DROP_NONE. Once the event.detail field is set on drag enter it will not be changed by SWT unless the user does something to change the operation such as hold down the shift key or the control key. What you are seeing is the correct feedback for DND.DROP_NONE. The reason you are setting the event.detail to DND.DROP_NONE is because in NavigatorDropAdaptor.validateTarget you return false with the message "Cannot move <file name>. The source and destination are the same". In subsequent drag over callbacks you are also getting the same error message from validateTarget even though the source is still <file name> from drag enter and the target passed in to validateTarget is whatever file or folder you are currently above. Note that on motif there is no API in Table to have both a selection and a "drop selection". On windows, I can call native code to get this effect. Therefore, as the cursor moves over different items in the tree, the selection in the tree changes. If you are asking the tree for its current selection to determine the drag source data each time you get an event, then you will not get the correct info. You need to store the drag source selection somewhere when the drag source initiates the drag and not rely on the selection in the tree. As an aside: Why does NavigatorDropAdapter implement its own tree expansion? ResourceNavigator.initDragAndDrop calls setFeedbackEnabled(false) which turns off the for free tree expansion provided by SWT. By doing your own expansion you are potentially behaving differently which is not good.
SWT must have done something a while ago because the original bug says I did not get a DragEnter event. Anyway, I realized that the way I do a local drag within the same widget is bogus and added a LocalSelectionTransfer when I fixed bug 29778. Drag move works fine. Drag move is not allowed within the same folder. It works when you drag to a different folder. Drag copy is a different story on Motif. The drop doesn't happen when I release the mouse. I'll have to look into it. validateTarget returns true in that case so it should work. setFeedbackEnabled(false) only turns off the insertion feedback. I'm not sure why the navigator does its own auto expand. Perhaps SWT added that feature at some point when the navigator drop support was already written? I'll get rid of the code. Thanks for pointing it out!
I figured out why copy does not work. When the dragged item is already selected I get all the normal drag behavior except for the final drop event. When the dragged item is not selected when I start the drag (i.e., the drag click selects it) I do get the drop event and the drag succeeds.
Updated bug 30249 with the findings from comment #6. Closing this bug since original problem is fixed.