Search code examples
javaeclipsegwttreesmartgwt

Events combination SmartGWT


I'm working on Java, SmartGWT 2.5 & Mozilla FF 3.6.x. I'm using Tree, TreeGrid & TreeNode in my application. I need to drag a node and while dragging I have to see the other nodes on which mouse will pass with changed background color. I tried with dragStart, dragStop, onCellOver, onCellOut and dragMove, but maybe I don't make a good combination of them. So, how can be these events combinated to get what I need?


Solution

  • Add a DropOverHandler on the target widget (a TreeGrid in this case).

    You'll then need to use one of the many available styling APIs (probably getCellCSSText()) so that it returns different results while the mouse remains over the target grid, and call markForRedraw() on the grid from DropOver so that your new styling is applied.

    Overriding willAcceptDrop() is how you tell the system whether dropping on a particular row is allowed (affects the mouse cursor).

    Detect the mouse exiting the grid via the DropOut event, and call markForRedraw() again there.