0

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?

confile
  • 30,949
  • 47
  • 199
  • 357

1 Answers1

1

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?

Community
  • 1
  • 1
bdrx
  • 894
  • 12
  • 28