Using Java's MouseListener in Processing

edited April 2014 in How To...

Hi , I want to get Mouse Events outside processing's frame . I get the location easily by using MouseInfo Class but for MouseEvents (mousePressed and etc) I havent seen an example done in Processing .

I guess it's possible to get mouse events through MouseListener or MouseAdapter Class in Java but I dont know how to use it in Processing ./ thanx for help /

Answers

  • Are you saying you want to get mouse events outside of the whole Processing program, for example in other programs?

    This, uh, isn't possible.

    (Well, anything is arguably possible, but this is not trivial)

    MouseListeners (and MouseAdapters) are simply listeners on specific components inside a Java program. That's what Processing is using under the hood. They don't give access to information outside of the Java (or Processing) window.

    The only way to really do what you're describing is to write native code, which is going to be pretty gross.

  • Well , I've searched alot for a Global Mouse Listener in Java and found these :

    http://kra.lc/blog/2011/07/java-global-system-hook/ and a question about global mouse listener

    I hope someone check it out to see if its possible .

  • That first link is the native code approach that I mentioned, and the second link is a listener on a specific component, not outside the Java program.

    Doing a google search of "java detect mouse click outside component" returns a bunch of results, but they mostly just confirm what I've already said.

  • Moved from Questions about Code because you don't show any code.

Sign In or Register to comment.