Browser event and coordinates: Difference between revisions
From JSXGraph Wiki
(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...") |
No edit summary |
||
Line 29: | Line 29: | ||
board.addHook(up, 'mouseup'); | board.addHook(up, 'mouseup'); | ||
</jsxgraph> | </jsxgraph> | ||
[[Category:Examples]] |
Revision as of 08: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.