I'm trying to make a TextBox that will change value when someone scrolls the mouse wheel over it. Specifically, my goal is for the number in the text box to increase when i scroll up, and decrease when i scroll down. However, I'm having trouble figuring out the MouseWheelHandler. I simplified my code to just change the value to "UP" or "DOWN", but it just doesn't work. It compiles though. I also tried it with event.preventDefault(), but that didn't seem to have any effect.
private TextBox valueField = new TextBox();
...
...
valueField.addMouseWheelHandler(new MouseWheelHandler() {
public void onMouseWheel(MouseWheelEvent event) {
//event.preventDefault();
if(event.isNorth()) {
valueField.setText("UP");
} else {
valueField.setText("DOWN");
}
}
});
Edit: I just tested it in Chromium and Opera, and it worked fine. Unfortunately, it still does not work in my supported browsers (Firefox and IE).
Edit: Decided to try a native Javascript method. My Javascript skills are weak, so I still need some help.