We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › using the scroll wheel as input
Page Index Toggle Pages: 1
using the scroll wheel as input (Read 3534 times)
using the scroll wheel as input
Jun 22nd, 2006, 3:31pm
 
Hello,
how can I use the data that comes from my mouse scroll wheel as input?
thx4hlp
Re: using the scroll wheel as input
Reply #1 - Jun 22nd, 2006, 4:17pm
 
There is a mouse scroll event listener. My computer is being utilised to restore my flatmate's computer though (he says writing from the school library). Perhaps someone can post some example usage code The constructor for the object looks pretty convoluted. (I would also remind M that a lot of mac users won't be able to use this feature because of the "too cool for buttons" mouse).
Re: using the scroll wheel as input
Reply #2 - Jun 26th, 2006, 12:30am
 
I´d like to have some more details...
Wink
no, seriously, I´m not understanding any of this. What I actually need is the getWheelRotation() function. Could somebody give me a mere example, a piece of code that I just have to copy and paste? That would be great.

thxalot
*m
Re: using the scroll wheel as input
Reply #3 - Jun 26th, 2006, 2:09pm
 
Read the following link and experiment with the following code.

http://java.sun.com/docs/books/tutorial/uiswing/events/mousewheellistener.html

Quote:


MouseWheelEventDemo wheel;

void setup(){
 wheel = new MouseWheelEventDemo();
}
void draw(){
}

public class MouseWheelEventDemo implements MouseWheelListener {
 public MouseWheelEventDemo() {
   addMouseWheelListener(this);
 }
 public void mouseWheelMoved(MouseWheelEvent e) {
   String message;
   int notches = e.getWheelRotation();
   if (notches < 0) {
     message = "Mouse wheel moved UP "
       + -notches + " notch";
   }
   else {
     message = "Mouse wheel moved DOWN "
       + notches + " notch";
   }
   println(message);
 }
}




The wheel event listener always seems to be referenced in relation to textbox or something. Which is why I've given you a free lunch because it might not occur to you to register the listener with the processing applet (this). Generally one should only offer half the answer -> Zen wisdom Wink
Re: using the scroll wheel as input
Reply #4 - Jun 26th, 2006, 10:30pm
 
perfect. thank you. So much easier than finding an "endless" potentiometer and connecting it via microcontroller:)
Re: using the scroll wheel as input
Reply #5 - May 21st, 2009, 8:37am
 
m wrote on Jun 26th, 2006, 10:30pm:
perfect. thank you. So much easier than finding an "endless" potentiometer and connecting it via microcontroller:)


That's called a "rotary encoder", for the record.  Smiley

http://en.wikipedia.org/wiki/Rotary_encoder
Page Index Toggle Pages: 1