Adding events

From JSXGraph Wiki
Revision as of 09:04, 7 June 2011 by Michael (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Please note: This only works when the SVG or VML renderer is used. With the Canvas renderer the rendNode property is undefined.

 

<p id="myOutput">&nbsp;</p>
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-4,4,4,-4], keepaspectratio:true});
var myPoint = brd.create('point',[1,1], {size:5});
JXG.addEvent(myPoint.rendNode, 'mouseover', 
             function(){ document.getElementById('myOutput').innerHTML = "Point "+this.name;}, 
             myPoint);
JXG.addEvent(myPoint.rendNode, 'mouseout', 
             function(){document.getElementById('myOutput').innerHTML = '&nbsp;';}, 
             myPoint);
myPoint.hasPoint = function(){return false; };  // User can not move "A" anymore.

var myPoint2 = brd.create('point',[-1,1], {size:5});
JXG.addEvent(myPoint2.rendNode, 'mouseover', 
             function(){ document.getElementById('myOutput').innerHTML = "Point "+this.name;}, 
             myPoint2);
JXG.addEvent(myPoint2.rendNode, 'mouseout', 
             function(){document.getElementById('myOutput').innerHTML = '&nbsp;';}, 
             myPoint2);