@@ -116,6 +116,28 @@ var MouseManager = new Class({
116116 */
117117 this . onMouseUp = NOOP ;
118118
119+ /**
120+ * The Mouse Down Event handler specifically for events on the Window.
121+ * This function is sent the native DOM MouseEvent.
122+ * Initially empty and bound in the `startListeners` method.
123+ *
124+ * @name Phaser.Input.Mouse.MouseManager#onMouseDownWindow
125+ * @type {function }
126+ * @since 3.16.3
127+ */
128+ this . onMouseDownWindow = NOOP ;
129+
130+ /**
131+ * The Mouse Up Event handler specifically for events on the Window.
132+ * This function is sent the native DOM MouseEvent.
133+ * Initially empty and bound in the `startListeners` method.
134+ *
135+ * @name Phaser.Input.Mouse.MouseManager#onMouseUpWindow
136+ * @type {function }
137+ * @since 3.16.3
138+ */
139+ this . onMouseUpWindow = NOOP ;
140+
119141 /**
120142 * The Mouse Over Event handler.
121143 * This function is sent the native DOM MouseEvent.
@@ -282,6 +304,8 @@ var MouseManager = new Class({
282304
283305 this . onMouseDown = function ( event )
284306 {
307+ console . log ( 'down' ) ;
308+
285309 if ( autoFocus )
286310 {
287311 window . focus ( ) ;
@@ -301,6 +325,25 @@ var MouseManager = new Class({
301325 }
302326 } ;
303327
328+ this . onMouseDownWindow = function ( event )
329+ {
330+ console . log ( 'window down' ) ;
331+
332+ if ( event . defaultPrevented || ! _this . enabled || ! _this . manager )
333+ {
334+ // Do nothing if event already handled
335+ return ;
336+ }
337+
338+ if ( event . target !== canvas )
339+ {
340+ console . log ( 'window process' ) ;
341+
342+ // Only process the event if the target isn't the canvas
343+ _this . manager . queueMouseDown ( event ) ;
344+ }
345+ } ;
346+
304347 this . onMouseUp = function ( event )
305348 {
306349 if ( event . defaultPrevented || ! _this . enabled || ! _this . manager )
@@ -317,6 +360,21 @@ var MouseManager = new Class({
317360 }
318361 } ;
319362
363+ this . onMouseUpWindow = function ( event )
364+ {
365+ if ( event . defaultPrevented || ! _this . enabled || ! _this . manager )
366+ {
367+ // Do nothing if event already handled
368+ return ;
369+ }
370+
371+ if ( event . target !== canvas )
372+ {
373+ // Only process the event if the target isn't the canvas
374+ _this . manager . queueMouseUp ( event ) ;
375+ }
376+ } ;
377+
320378 this . onMouseOver = function ( event )
321379 {
322380 if ( event . defaultPrevented || ! _this . enabled || ! _this . manager )
@@ -355,10 +413,10 @@ var MouseManager = new Class({
355413 target . addEventListener ( 'mouseover' , this . onMouseOver , ( this . capture ) ? nonPassive : passive ) ;
356414 target . addEventListener ( 'mouseout' , this . onMouseOut , ( this . capture ) ? nonPassive : passive ) ;
357415
358- if ( window )
416+ if ( window && this . manager . game . config . inputWindowEvents )
359417 {
360- window . addEventListener ( 'mousedown' , this . onMouseDown , nonPassive ) ;
361- window . addEventListener ( 'mouseup' , this . onMouseUp , nonPassive ) ;
418+ window . addEventListener ( 'mousedown' , this . onMouseDownWindow , nonPassive ) ;
419+ window . addEventListener ( 'mouseup' , this . onMouseUpWindow , nonPassive ) ;
362420 }
363421
364422 if ( Features . pointerLock )
0 commit comments