@@ -75,6 +75,7 @@ class MouseControl extends CanvasSectionObject {
7575 modifier : number ,
7676 ) {
7777 let viewToDocumentPos = point . clone ( ) ;
78+ Util . ensureValue ( app . activeDocument ) ;
7879
7980 // Convert to pure canvas html element coordinate.
8081 viewToDocumentPos . pX +=
@@ -121,6 +122,7 @@ class MouseControl extends CanvasSectionObject {
121122
122123 // Gets the mouse position on browser page in CSS pixels.
123124 public getMousePagePosition ( ) {
125+ Util . ensureValue ( app . activeDocument ) ;
124126 const boundingClientRectangle = this . context . canvas . getBoundingClientRect ( ) ;
125127 const pagePosition = this . currentPosition . clone ( ) ;
126128 pagePosition . pX -=
@@ -141,6 +143,7 @@ class MouseControl extends CanvasSectionObject {
141143 }
142144
143145 private refreshPosition ( point : cool . SimplePoint ) {
146+ Util . ensureValue ( app . activeDocument ) ;
144147 let topLeftX = app . activeDocument . activeLayout . viewedRectangle . pX1 ;
145148 let topLeftY = app . activeDocument . activeLayout . viewedRectangle . pY1 ;
146149
@@ -161,6 +164,7 @@ class MouseControl extends CanvasSectionObject {
161164 else if ( app . map . _docLayer . _docType === 'spreadsheet' ) {
162165 const textCursor =
163166 app . file . textCursor . visible &&
167+ app . calc . cellCursorRectangle &&
164168 app . calc . cellCursorRectangle . pContainsPoint (
165169 this . currentPosition . pToArray ( ) ,
166170 ) ;
@@ -202,6 +206,8 @@ class MouseControl extends CanvasSectionObject {
202206 this . amplitude [ 1 ] * Math . exp ( - elapsed / 650 ) ,
203207 ] ;
204208
209+ Util . ensureValue ( app . activeDocument ) ;
210+
205211 if ( Math . abs ( delta [ 0 ] ) > 0.2 || Math . abs ( delta [ 1 ] ) > 0.2 ) {
206212 app . activeDocument . activeLayout . scrollTo (
207213 app . activeDocument . activeLayout . viewedRectangle . pX1 + delta [ 0 ] ,
@@ -291,6 +297,7 @@ class MouseControl extends CanvasSectionObject {
291297 diff . x -= this . positionOnMouseDown . x ;
292298 diff . y -= this . positionOnMouseDown . y ;
293299
300+ Util . ensureValue ( app . activeDocument ) ;
294301 const viewedRectangle =
295302 app . activeDocument . activeLayout . viewedRectangle . clone ( ) ;
296303
@@ -399,10 +406,11 @@ class MouseControl extends CanvasSectionObject {
399406 else if ( app . map . _docLayer . _docType === 'spreadsheet' ) {
400407 const acceptInput =
401408 app . calc . cellCursorVisible &&
409+ app . calc . cellCursorRectangle &&
402410 app . calc . cellCursorRectangle . containsPoint (
403411 this . currentPosition . toArray ( ) ,
404412 ) ;
405- return acceptInput ;
413+ return acceptInput as boolean ;
406414 } else return false ;
407415 }
408416
0 commit comments