how to use the mousewheel in processing

Nikolaus Gradwohl2010-08-01T20:16:38+00:00

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() {
  addMouseWheelListener(new java.awt.event.MouseWheelListener() { 
    public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { 

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.

Tweet This! submit to reddit Digg! Tags: | 1 comments | no trackbacks

See also:

sketch experiment 7 - osc events
nested cubes in processing
processing phaseflower
Time Perception
de jong attractor



Leave a response

  1. srinidhi nakshatri 2012-12-19T08:19:29+00:00

    How can we insert jre lib in processing because you are using java.awt.event.MouseWheelListener

Leave a comment