List of usage examples for com.vaadin.client Util getElementUnderMouse
@Deprecated public static com.google.gwt.user.client.Element getElementUnderMouse(NativeEvent event)
From source file:fi.jasoft.draganddrop.client.configurations.OrderedLayoutDragAndDropConfiguration.java
License:Apache License
protected Slot getSlot(DragAndDropEvent event) { Element e = Util.getElementUnderMouse(event.getEvent()); /*/* w ww. j av a2 s .c om*/ * If we are hitting between slot search around the cursor for the * closest slot */ int nextDirection = 0; int width = 1; int pageX = Util.getTouchOrMouseClientX(event.getEvent()); int pageY = Util.getTouchOrMouseClientY(event.getEvent()); while (event.getTargetConnector().getWidget().getElement() == e) { if (nextDirection == 0) { pageY -= width; nextDirection++; } else if (nextDirection == 1) { pageX += width; nextDirection++; } else if (nextDirection == 2) { pageY += width; nextDirection++; } else if (nextDirection == 3) { pageX -= width; width++; nextDirection = 0; } e = Util.getElementFromPoint(pageX, pageY); } assert e != null : "Event target was null"; Widget w = Util.findWidget(e, null); assert w != null : "Widget was not found"; if (w != null) { while (!(w instanceof Slot) && w != null) { w = w.getParent(); } } assert w instanceof Slot; return (Slot) w; }
From source file:fi.jasoft.draganddrop.client.DragAndDropConnector.java
License:Apache License
private static DragAndDropConnector getTargetConnector(NativeEvent event) { Node node;//from w ww . jav a2 s . c o m if (dragElement != null) { dragElement.getStyle().setDisplay(Display.NONE); node = Util.getElementUnderMouse(event); dragElement.getStyle().setDisplay(Display.BLOCK); if (node == null) { return null; } } else if (event.getEventTarget() != null) { node = Node.as(event.getEventTarget()); } else { return null; } return getTargetConnector(node); }