public void setMouseWheelMoved(JavaScriptObject aValue) { if (mouseWheelMoved != aValue) { if (mouseWheelReg != null) { mouseWheelReg.removeHandler(); mouseWheelReg = null; } mouseWheelMoved = aValue; if (mouseWheelMoved != null) { MouseWheelHandler handler = new MouseWheelHandler() { @Override public void onMouseWheel(MouseWheelEvent event) { if (mouseWheelMoved != null) { event.stopPropagation(); executeEvent(mouseWheelMoved, EventsPublisher.publish(event)); } } }; if (component instanceof Widget) { mouseWheelReg = ((Widget) component).addDomHandler(handler, MouseWheelEvent.getType()); } else if (component instanceof HasMouseWheelHandlers) { mouseWheelReg = ((HasMouseWheelHandlers) component).addMouseWheelHandler(handler); } } } }