home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 July / PCpro_2004_07.ISO / docs / maxblast / maxblast3_files / thing_003.js < prev    next >
Encoding:
Text File  |  2004-03-07  |  2.6 KB  |  112 lines

  1.  
  2. Thing.prototype.captureMouseClick = function( fcn ){
  3.     var doc;
  4.     if( is.ns4 ){
  5.         doc = this.div.document;
  6.         doc.captureEvents( Event.MOUSECLICK );
  7.     }
  8.     else{
  9.         doc = this.div;
  10.     }
  11.     doc.thing = this;
  12.     if( fcn ) this.mouseClick = fcn;
  13.     
  14.     doc.onclick = function(e){
  15.         return this.thing.mouseClick( this.thing.getMousePosition(e) );
  16.     }
  17. }
  18. Thing.prototype.mouseClick = function(p){ /* overwrite me */ }
  19.  
  20.  
  21. Thing.prototype.captureMouseDown = function( fcn ){
  22.     var doc;
  23.     if( is.ns4 ){
  24.         doc = this.div.document;
  25.         doc.captureEvents( Event.MOUSEDOWN );
  26.     }
  27.     else{
  28.         doc = this.div;
  29.     }
  30.     doc.thing = this;
  31.     if( fcn ) this.mouseDown = fcn;
  32.     doc.onmousedown = function(e){
  33.         return this.thing.mouseDown( this.thing.getMousePosition(e) );
  34.     }
  35. }
  36. Thing.prototype.mouseDown = function(p){ /* overwrite me */ }
  37.  
  38.  
  39.  
  40. Thing.prototype.captureMouseUp = function( fcn ){
  41.     var doc;
  42.     if( is.ns4 ){
  43.         doc = this.div.document;
  44.         doc.captureEvents( Event.MOUSEUP );
  45.     }
  46.     else{
  47.         doc = this.div;
  48.     }
  49.     doc.thing = this;
  50.     if( fcn ) this.mouseUp = fcn;
  51.     doc.onmouseup = function(e){
  52.         return this.thing.mouseUp( this.thing.getMousePosition(e) );
  53.     }
  54. }
  55. Thing.prototype.mouseUp = function(p){ /* overwrite me */ }
  56.  
  57. Thing.prototype.captureMouseMove = function( fcn ){
  58.     var doc;
  59.     if( is.ns4 ){
  60.         doc = this.div.document;
  61.         doc.captureEvents( Event.MOUSEMOVE );
  62.     }
  63.     else{
  64.         doc = this.div;
  65.     }
  66.     doc.thing = this;
  67.     if( fcn ) this.mouseMove = fcn;
  68.     doc.onmousemove = function(e){
  69.         return this.thing.mouseMove( this.thing.getMousePosition(e) );
  70.     }
  71. }
  72. Thing.prototype.mouseMove = function(p){ /* overwrite me */ }
  73.  
  74. Thing.prototype.captureMouseOver = function( fcn ){
  75.     var doc;
  76.     if( is.ns4 ){
  77.         doc = this.div.document;
  78.         doc.captureEvents( Event.MOUSEOVER );
  79.     }
  80.     else{
  81.         doc = this.div;
  82.     }
  83.     doc.thing = this;
  84.     if( fcn ) this.mouseOver = fcn;
  85.     doc.onmouseover = function(e){
  86.         return this.thing.mouseOver( this.thing.getMousePosition(e) );
  87.     }
  88. }
  89. Thing.prototype.mouseOver = function(p){ /* overwrite me */ }
  90.  
  91. Thing.prototype.captureMouseOut = function( fcn ){
  92.     var doc;
  93.     if( is.ns4 ){
  94.         doc = this.div.document;
  95.         doc.captureEvents( Event.MOUSEOUT );
  96.     }
  97.     else{
  98.         doc = this.div;
  99.     }
  100.     doc.thing = this;
  101.     if( fcn ) this.mouseOut = fcn;
  102.     doc.onmouseout = function(e){
  103.         return this.thing.mouseOut( this.thing.getMousePosition(e) );
  104.     }
  105. }
  106. Thing.prototype.mouseOut = function(p){ /* overwrite me */ }
  107.  
  108. Thing.prototype.getMousePosition = function(e){
  109.     var p = ( is.ns4 || is.ns6 ) ? new Point( e.pageX - pageXOffset, e.pageY - pageYOffset ) : new Point( event.clientX, event.clientY );
  110.     return p.sub( this.getPosition() );
  111. }
  112.