Skip to content

Commit 02ac6bc

Browse files
committed
If inputWindowEvents is set in the Game Config, then the MouseManager will now listen for the events on window.top instead of just window, which should help in situations where the pointer is released outside of an embedded iframe. Fix phaserjs#4824
1 parent 4c35357 commit 02ac6bc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/input/mouse/MouseManager.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ var NOOP = require('../../utils/NOOP');
1515
/**
1616
* @classdesc
1717
* The Mouse Manager is a helper class that belongs to the Input Manager.
18-
*
18+
*
1919
* Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing.
20-
*
20+
*
2121
* You do not need to create this class directly, the Input Manager will create an instance of it automatically.
2222
*
2323
* @class MouseManager
@@ -222,9 +222,9 @@ var MouseManager = new Class({
222222

223223
/**
224224
* Attempts to disable the context menu from appearing if you right-click on the browser.
225-
*
225+
*
226226
* Works by listening for the `contextmenu` event and prevent defaulting it.
227-
*
227+
*
228228
* Use this if you need to enable right-button mouse support in your game, and the browser
229229
* menu keeps getting in the way.
230230
*
@@ -306,7 +306,7 @@ var MouseManager = new Class({
306306
if (!event.defaultPrevented && _this.enabled && _this.manager && _this.manager.enabled)
307307
{
308308
_this.manager.onMouseMove(event);
309-
309+
310310
if (_this.capture)
311311
{
312312
event.preventDefault();
@@ -324,7 +324,7 @@ var MouseManager = new Class({
324324
if (!event.defaultPrevented && _this.enabled && _this.manager && _this.manager.enabled)
325325
{
326326
_this.manager.onMouseDown(event);
327-
327+
328328
if (_this.capture && event.target === canvas)
329329
{
330330
event.preventDefault();
@@ -346,7 +346,7 @@ var MouseManager = new Class({
346346
if (!event.defaultPrevented && _this.enabled && _this.manager && _this.manager.enabled)
347347
{
348348
_this.manager.onMouseUp(event);
349-
349+
350350
if (_this.capture && event.target === canvas)
351351
{
352352
event.preventDefault();
@@ -406,8 +406,8 @@ var MouseManager = new Class({
406406

407407
if (window && this.manager.game.config.inputWindowEvents)
408408
{
409-
window.addEventListener('mousedown', this.onMouseDownWindow, nonPassive);
410-
window.addEventListener('mouseup', this.onMouseUpWindow, nonPassive);
409+
window.top.addEventListener('mousedown', this.onMouseDownWindow, nonPassive);
410+
window.top.addEventListener('mouseup', this.onMouseUpWindow, nonPassive);
411411
}
412412

413413
if (Features.pointerLock)
@@ -448,8 +448,8 @@ var MouseManager = new Class({
448448

449449
if (window)
450450
{
451-
window.removeEventListener('mousedown', this.onMouseDownWindow);
452-
window.removeEventListener('mouseup', this.onMouseUpWindow);
451+
window.top.removeEventListener('mousedown', this.onMouseDownWindow);
452+
window.top.removeEventListener('mouseup', this.onMouseUpWindow);
453453
}
454454

455455
if (Features.pointerLock)

0 commit comments

Comments
 (0)