Difference between revisions of "Browser event and coordinates"

From JSXGraph Wiki
Jump to: navigation, search
(Created page with "This example shows how to add a point whenever the user clicks on the board. The function getMouseCoords extracts the click coordinates from the event object and returns a JXG.Co...")
 
Line 29: Line 29:
 
     board.addHook(up, 'mouseup');
 
     board.addHook(up, 'mouseup');
 
</jsxgraph>
 
</jsxgraph>
 +
 +
 +
[[Category:Examples]]

Revision as of 09:07, 21 March 2011

This example shows how to add a point whenever the user clicks on the board. The function getMouseCoords extracts the click coordinates from the event object and returns a JXG.Coords object with the point's coordinates on the board. up() is the event listener attached to the board via board.addHook(). The for loop in the event listener is to check if there is already a point as we don't want to create a point in this case.