I have a GWT ScrollPanel with a horizontal scrollbar, i.e.
overflow-y: scroll;
How can I bind a MouseWheel event on the scroll bar to perform a horizontal scrolling when the mouse wheel is moved?
I have a GWT ScrollPanel with a horizontal scrollbar, i.e.
overflow-y: scroll;
How can I bind a MouseWheel event on the scroll bar to perform a horizontal scrolling when the mouse wheel is moved?
See this example of how to listen to a mouse wheel event: http://examples.roughian.com/index.htm#Listeners~MouseWheelListener
Instead of a label extend a ScrollPanel
Instead of setText
call setHorizontalScrollPosition(int position)
public void onMouseWheel(Widget sender, MouseWheelVelocity velocity)
{
DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); //prevent vertical scroll
int positionDelta = velocity.getDeltaY() * 30;
int newPosition = getHorizontalScrollPosition() - positionDelta;
setHorizontalScrollPosition(newPosition);
}
Also see How to do a horizontal scroll on mouse wheel scroll?