NatTable cursor switch into selection mode after DND

80 Views Asked by At

I have nattable with grid. I introduced own drag listener which implements DragSourceListener. DND works well - is possible drag some item and drop it into some group of item. When is drop executes above item which is not valid for drop, nothing happens.

But problem is that after valid or not valid drop is cursor switched into some "selection mode". So both buttons on mouse are not pressed, but when I moving the cursor above cells, then is highlited rectangle which is defined by cell where was executed drop (left mouse button was released) and by actual cursor position. Simply words this behaviour is the same as multi selection of cells by cursor moving with pressed left mouse button. This strange behaviour is possible terminate by click on some cell. Then moving cursor above cells nothing do and remains highlited selected area, which is canceled by another mouse click. When is dragging canceled by ESC key, so drop is not execute, then this problem not occures.

Summarization - after release left button during dragging the cursor remains in some like selection mode, but mouse buttons are not pressed.

Is needed call something after drop? Some tips for reason of this problem?

1

There are 1 best solutions below

1
Dirk Fauth On

My best guess is that the interactions on dragging an item are mixed up, since you implemented a DragSourceListener which is base SWT, and there are drag listeners inside NatTable.

Typically interaction listeners in NatTable should be implemented via NatTable API. As you only want to deal with drag & drop support inside a single NatTable instance, you should implement and register an IDragMode similar to the ColumnReorderDragMode for example. This way you are under full control what happens inside the NatTable and don't need to deal with SWT drag & drop in combination with NatTable UI bindings.