Skip to content

Commit 1932515

Browse files
committed
Fixed a really nasty bug in Chrome OS X where a ctrl + click (i.e. simulated right-click) on a trackpad would lock up the Pointer leftButton, causing future clicks to fail. This is now handled by way of a mouseout listener on the window object, sadly the only way to force a mouseup in Chrome (thanks @kyleu phaserjs#2286)
1 parent 4426c71 commit 1932515

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
374374
* Both `transparent` and `antialias` were ignored if set to `false` in a Game configuration object, as the `parseConfig` method didn't check for falsey values (thanks @amadeus #2302)
375375
* GameObject.revive used to add the health amount given to the Game Object (via `heal`) instead of setting it as the new health amount. It now calls `setHealth` instead, giving it the exact amount (thanks @netgfx #2231)
376376
* Group.add and Group.addAt would forget to remove the child from the hash of its previous Group if it had a physics body enabled, causing unbounded hash increase (thanks @strawlion @McIntozh #2232)
377+
* Fixed a really nasty bug in Chrome OS X where a ctrl + click (i.e. simulated right-click) on a trackpad would lock up the Pointer leftButton, causing future clicks to fail. This is now handled by way of a mouseout listener on the window object, sadly the only way to force a mouseup in Chrome (thanks @KyleU #2286)
377378

378379
### Pixi Updates
379380

src/input/Mouse.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ Phaser.Mouse.prototype = {
245245
return _this.onMouseUpGlobal(event);
246246
};
247247

248+
this._onMouseOutGlobal = function (event) {
249+
return _this.onMouseOutGlobal(event);
250+
};
251+
248252
this._onMouseOut = function (event) {
249253
return _this.onMouseOut(event);
250254
};
@@ -266,6 +270,7 @@ Phaser.Mouse.prototype = {
266270
if (!this.game.device.cocoonJS)
267271
{
268272
window.addEventListener('mouseup', this._onMouseUpGlobal, true);
273+
window.addEventListener('mouseout', this._onMouseOutGlobal, true);
269274
canvas.addEventListener('mouseover', this._onMouseOver, true);
270275
canvas.addEventListener('mouseout', this._onMouseOut, true);
271276
}
@@ -400,6 +405,42 @@ Phaser.Mouse.prototype = {
400405

401406
},
402407

408+
/**
409+
* The internal method that handles the mouse out event from the window.
410+
*
411+
* @method Phaser.Mouse#onMouseOutGlobal
412+
* @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
413+
*/
414+
onMouseOutGlobal: function (event) {
415+
416+
this.event = event;
417+
418+
if (this.capture)
419+
{
420+
event.preventDefault();
421+
}
422+
423+
this.input.mousePointer.withinGame = false;
424+
425+
if (!this.input.enabled || !this.enabled)
426+
{
427+
return;
428+
}
429+
430+
// If we get a mouseout event from the window then basically
431+
// something serious has gone down, usually along the lines of
432+
// the browser opening a context-menu or similar.
433+
// On OS X Chrome especially this is bad news, as it blocks
434+
// us then getting a mouseup event, so we need to force that through.
435+
//
436+
// No matter what, we must cancel the left and right buttons
437+
438+
this.input.mousePointer.stop(event);
439+
this.input.mousePointer.leftButton.stop(event);
440+
this.input.mousePointer.rightButton.stop(event);
441+
442+
},
443+
403444
/**
404445
* The internal method that handles the mouse out event from the browser.
405446
*

src/input/Pointer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ Phaser.Pointer.prototype = {
557557

558558
if (event.ctrlKey && this.leftButton.isDown)
559559
{
560+
this.leftButton.stop(event);
560561
this.rightButton.start(event);
561562
}
562563

0 commit comments

Comments
 (0)