Took advantage of the advice given in this thread . I do it in the second way, but this hardly affects the situation. Columns of the table perfectly resize. But there is one problem. If I take the cursor outside the browser window, then my application does not catch events. So it may happen that the user has already released the button, and when the cursor returns to the window, the movement begins again. Logically, columns should normally resize regardless of whether the cursor is inside or outside the browser window. In google-docs this works in some way. At the moment I do something like this:

Resizer catches the mouse-down event and disables the selection in the browser (applies the style), and also adds listeners to the RootPanel:

handlerRegistrations.add(RootPanel.get().addDomHandler(new MouseUpHandler() { public void onMouseUp(MouseUpEvent e) { resize(e); setDragged(false); } }, MouseUpEvent.getType()); ); handlerRegistrations.add(RootPanel.get().addDomHandler(new MouseMoveHandler() { public void onMouseMove(MouseMoveEvent e) { resize(e); } }, MouseMoveEvent.getType()); ); handlerRegistrations.add(RootPanel.get().addDomHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent e) { setDragged(false); } }, MouseOutEvent.getType()); ); 

To stop dragging, I delete all these listeners (I clear the handlerRegistrations) and allow the selection again in the browser. As you can see, now if we move the mouse out of the window, we stop dragging.

How can you still do to catch events outside the browser?

  • Excuse me, but it is not clear how you did "RootPanel.get (). AddDomHandler" -? After all, this method is protected .. - cy6erGn0m
  • addDomHandler is a public method. You probably use the old GWT. google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/… - angry
  • Oh, sorry. I work with 2.0 and have not bothered to deal with innovations 2.1. - cy6erGn0m

2 answers 2

Try to look at Sauer’s examples . There are links to the code. The author uses Drag and Drop. If you look at other examples, you can see that DragAndDrop does not have the shortage indicated by you, since the mouse is captured and continues dragging even if the mouse is outside the window. And if you let go, the DnD is interrupted.

    Right. In your case, only events that occur in <body> will come.

    So that all events will come to your widget, including and outside the browser window:

     DOM.setCapture(widget.getElement()); 

    To undo this effect:

     DOM.releaseCapture(widget.getElement());