Reverse engineering the GWT event handler code to add new events is simple. Here’s a Flex Table which also handles mouse events:
/** * Internal flex table declaration that syncs mouse down/move/up events */ private static class MouseFlexTable extends FlexTable implements HasAllMouseHandlers { @Override public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { return addDomHandler(handler, MouseDownEvent.getType()); } @Override public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) { return addDomHandler(handler, MouseUpEvent.getType()); } @Override public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) { return addDomHandler(handler, MouseOutEvent.getType()); } @Override public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) { return addDomHandler(handler, MouseOverEvent.getType()); } @Override public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) { return addDomHandler(handler, MouseMoveEvent.getType()); } @Override public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) { return addDomHandler(handler, MouseWheelEvent.getType()); } }
Addendum:
If you want the location (the cell) in which the mouse event happened, you can extend MouseFlexTable with the additional methods:
public static class HTMLCell { private final int row; private final int col; private HTMLCell(int r, int c) { row = r; col = c; } public int getRow() { return row; } public int getCol() { return col; } } public HTMLCell getHTMLCellForEvent(MouseEvent event) { Element td = getEventTargetCell(Event.as(event.getNativeEvent())); if (td == null) { return null; } int row = TableRowElement.as(td.getParentElement()).getSectionRowIndex(); int column = TableCellElement.as(td).getCellIndex(); return new HTMLCell(row, column); }