Permalink
Browse files

Update ControlP5mouseWheel example to use Processing 2.2's mouseWheel…

… callback.
  • Loading branch information...
danbernier committed May 7, 2015
1 parent 636adcc commit 46e173c6fa51ba70a1bace80e492f343a6dc9862
Showing with 7 additions and 11 deletions.
  1. +7 −11 examples/extra/ControlP5mouseWheel/ControlP5mouseWheel.pde
@@ -79,15 +79,11 @@ void controlEvent(ControlEvent event) {
}
// When working in desktop mode, you can add mousewheel support for
// controlP5 by using java.awt.event.MouseWheelListener and
// java.awt.event.MouseWheelEvent
void addMouseWheelListener() {
frame.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
cp5.setMouseWheelRotation(e.getWheelRotation());
}
// controlP5 by using Processing 2.2's built-in support:
void mouseWheel(MouseEvent e) {
// Processing's `getCount()` returns 1 when the mouseWheel is rotated down,
// and -1 when the mouseWheel is rotated up.
// Natural scrolling reverses this, so you need to negate the count value.
// Try removing the negation, if the scrolling is backwards for you.
cp5.setMouseWheelRotation(-e.getCount());
}
);
}

0 comments on commit 46e173c

Please sign in to comment.