Difference between revisions of "Adding events"

From JSXGraph Wiki
Jump to navigationJump to search
Line 20: Line 20:
 
             function(){document.getElementById('myOutput').innerHTML = ' ';},  
 
             function(){document.getElementById('myOutput').innerHTML = ' ';},  
 
             myPoint2);
 
             myPoint2);
//myPoint2.hasPoint = function(){return false; };
 
 
</jsxgraph>
 
</jsxgraph>
  
Line 28: Line 27:
  
 
<source lang="javascript">
 
<source lang="javascript">
 +
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; };
 +
 +
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);
 
</source>
 
</source>
  
 
[[Category:Examples]]
 
[[Category:Examples]]

Revision as of 13:26, 28 July 2010

 

<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; };

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);