how to use the mousewheel in processing
Mouse-events like move, drag or click are very simple to implement in processing. Only the mouse-wheel needs some special handling.
To get the mouseWheel events in processing the sketch needs to register a mouseWheelListener int the setup method
void setup() {
size(300,300);
smooth();
addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
mouseWheel(evt.getWheelRotation());
}});
}
and then a handler function that gets called by the listener every time the mousewheel is triggered
void mouseWheel(int delta) {
}
The value of delta indicates the direction and the speed by which that scroll-wheel has been turned.
Click here to see an applet that implements the callback function and zooms some rects.
See also:
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor
How can we insert jre lib in processing because you are using java.awt.event.MouseWheelListener