public void setMousePressed(JavaScriptObject aValue) { if (mousePressed != aValue) { if (mouseDownReg != null) { mouseDownReg.removeHandler(); mouseDownReg = null; } mousePressed = aValue; if (mousePressed != null) { MouseDownHandler handler = new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { if (mousePressed != null) { event.stopPropagation(); // Event.setCapture(event.getRelativeElement()); mouseState = MOUSE.PRESSED; executeEvent(mousePressed, EventsPublisher.publish(event)); } } }; if (component instanceof Widget) { mouseDownReg = ((Widget) component).addDomHandler(handler, MouseDownEvent.getType()); } else if (component instanceof HasMouseDownHandlers) { mouseDownReg = ((HasMouseDownHandlers) component).addMouseDownHandler(handler); } } } }
@Override protected void initAreas(Board board) { SVGElement area = (SVGElement) svg.getElementById("area"); NodeList<Element> nodeList = area.getElementsByTagName("path"); for (int i = 0; i < nodeList.getLength(); ++i) { SVGElement item = (SVGElement) nodeList.getItem(i); OMElement node = OMElement.convert(item); ((HasMouseMoveHandlers) node).addMouseMoveHandler(this); ((HasMouseDownHandlers) node).addMouseDownHandler(this); } }