> If I have ui elements in a canvas that I want to be clickable - what
> is the best way to go about doing that? Do I need to create some kind
> of collision detection to see if the mouse x,y is in a region? Or is
> there some better way?
You can:
1. Attach a function to the canvas onclick event
2. Get the mouse coords from the resultant event object.
3. Those, combined with some magic, will help you get the position of
the mouse cursor.
Below is a function which I use. If nested within a TABLE though, it
doesn't seem to work. :-( Any amount of DIV nesting does though. You
can see it in action here: http://dev.rgraph.org The top graph has
clickable bars.
http://www.phpguru.org/downloads/mousecoords.txt
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)