From 5f2b6a2b8252b8d89541ea1c51927e8b796642a1 Mon Sep 17 00:00:00 2001 From: kfrajer Date: Sat, 9 Sep 2017 23:53:06 -0600 Subject: [PATCH] Mouse wheel event updated Removed addMouseWheelListener() and used provided Processing.event.* to manipulate wheel action. This allows to run sketches in Processing version 3. --- .../examples/MapThing/MapThing.pde | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/distribution/MapThing-1.5/examples/MapThing/MapThing.pde b/distribution/MapThing-1.5/examples/MapThing/MapThing.pde index d16fd94..4c67e7b 100644 --- a/distribution/MapThing-1.5/examples/MapThing/MapThing.pde +++ b/distribution/MapThing-1.5/examples/MapThing/MapThing.pde @@ -153,14 +153,6 @@ void setup() { labelFont = loadFont("Serif-16.vlw"); textFont(labelFont); textSize(12); - - // Needed to add a mouse wheel listener to the - // applet window. - addMouseWheelListener(new java.awt.event.MouseWheelListener() { - public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { - mouseWheel(evt.getWheelRotation()); - } - }); } void draw() { @@ -234,13 +226,14 @@ void draw() { /** * Uses mouse wheel movement (also works with * MacBook-type track pads) to zoom in and out. - * @param delta: the movement of the mouse wheel + * @param event: Processing object */ -void mouseWheel(int delta) { - scaleFactor += delta * mouseWheelMultiple; - if (scaleFactor <= minScaleFactor) { - scaleFactor = minScaleFactor; - } +void mouseWheel(MouseEvent event) { + float e = event.getCount(); + scaleFactor += e * mouseWheelMultiple; + if (scaleFactor <= minScaleFactor) { + scaleFactor = minScaleFactor; + } } /** @@ -317,4 +310,4 @@ void keyPressed() { } else if (key == 'q') { exit(); } -} \ No newline at end of file +}