We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi , I'm looking for a way to get Mouse Wheel data while processing is running on background . this one only works when output panel is active .
void setup() {
size(100, 100);
}
void draw() {}
void mouseWheel(MouseEvent event) {
float e = event.getCount();
println(e);
}
Answers
Hello! I'm not an expert on this myself, but my understanding is that Java alone is only able to determine such events for the application window itself. To get mouse events while an application is out of focus, you need to use Java's Native Interface (JNI) to access global events by setting up hooks to prepend your own code to the system's normal actions upon those global events. How this is done can vary depending on the system also, so it sounds tricky to set up yourself.
Personally, I would try first to use a library called jnativehook, which provides global keyboard and mouse listeners for Java. You'd need to set up your program as a regular java program in Eclipse and include the library's jar file in your class path.
Here's some links to get you started...
For running processing sketches in a normal java program: https://processing.org/tutorials/eclipse/
Download page for jnativehook: https://github.com/kwhat/jnativehook/releases
Example code including a global mouse wheel listener: https://code.google.com/p/jnativehook/wiki/examples
I hope that's helpful, and good luck to you.