File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -101,16 +101,19 @@ class Mouse {
101101            if  ( ! ( data . x  >  0  &&  data . x  <  data . canvasWidth  && 
102102                data . y  >  0  &&  data . y  <  data . canvasHeight ) )  return ; 
103103
104+             // target will not exist if project is still loading 
104105            const  target  =  this . _pickTarget ( data . x ,  data . y ) ; 
105-             const  isNewMouseDown  =  ! previousDownState  &&  this . _isDown ; 
106-             const  isNewMouseUp  =  previousDownState  &&  ! this . _isDown ; 
107- 
108-             // Draggable targets start click hats on mouse up. 
109-             // Non-draggable targets start click hats on mouse down. 
110-             if  ( target . draggable  &&  isNewMouseUp )  { 
111-                 this . _activateClickHats ( target ) ; 
112-             }  else  if  ( ! target . draggable  &&  isNewMouseDown )  { 
113-                 this . _activateClickHats ( target ) ; 
106+             if  ( target )  { 
107+                 const  isNewMouseDown  =  ! previousDownState  &&  this . _isDown ; 
108+                 const  isNewMouseUp  =  previousDownState  &&  ! this . _isDown ; 
109+ 
110+                 // Draggable targets start click hats on mouse up. 
111+                 // Non-draggable targets start click hats on mouse down. 
112+                 if  ( target . draggable  &&  isNewMouseUp )  { 
113+                     this . _activateClickHats ( target ) ; 
114+                 }  else  if  ( ! target . draggable  &&  isNewMouseDown )  { 
115+                     this . _activateClickHats ( target ) ; 
116+                 } 
114117            } 
115118        } 
116119    } 
Original file line number Diff line number Diff line change 1+ const  { test}  =  require ( 'tap' ) ; 
2+ const  Runtime  =  require ( '../../src/engine/runtime' ) ; 
3+ 
4+ test ( 'isDown does not error before project loads' ,  t  =>  { 
5+     const  rt  =  new  Runtime ( ) ; 
6+     rt . ioDevices . mouse . postData ( { 
7+         isDown : true , 
8+         x : 20 , 
9+         y : 20 , 
10+         canvasWidth : 100 , 
11+         canvasHeight : 100 
12+     } ) ; 
13+     t . end ( ) ; 
14+ } ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments