Put your mouse cursor in the box and use the mouse wheel. The amount that the number will change each click will depend on your settings in Control Panel - Mouse - Wheel - Vertical Scrolling.
This is a listener is fired when the mouse wheel is scrolled. Within the
MouseWheelVelocity information, there is getDeltaY
which is a signed int indicating how far the wheel moves.
Note that you need DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
or else the event will fall through to the widget underneath and the whole damn
screen will scroll at the same time.
class Demo extends Label implements MouseWheelListener
{
// Scroll position
private int count = 0;
public Demo()
{
setText("Count = " + count);
addMouseWheelListener(this);
DOM.setStyleAttribute(getElement(), "border", "1px dotted red");
DOM.setStyleAttribute(getElement(), "padding", "20px");
}
public void onMouseWheel(Widget sender, MouseWheelVelocity velocity)
{
count += velocity.getDeltaY();
setText("Count = " + count);
DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
}
}