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 › Mouse over detection for PShape objects
Page Index Toggle Pages: 1
Mouse over detection for PShape objects (Read 1507 times)
Mouse over detection for PShape objects
Apr 16th, 2010, 2:05pm
 
I'm building a geographic map visualization and have code that builds a chloroplath map of the US using an SVG file and PShape.

I want to do tool tips and other mouse-based events upon hovering over a particular county in the map. Every county is currently a child of the PShape called "county" and identified by a unique ID. How can I either bind a mouse event listener to every county on the map, or create a detection system where the mouse coordinates are measured and somehow the county "child" under the mouse is detected.

Any assistance with this would be great!
Re: Mouse over detection for PShape objects
Reply #1 - Apr 17th, 2010, 2:31am
 
The Geomerative library is able to handle that, I think.
Otherwise, the common solution is to draw each shape on an off-screen buffer with a unique color. Then you map mouse position on this buffer and check the color it is over: that's the ID of your shape!
Page Index Toggle Pages: 1