mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Added option to disable context menu
Added to both the game config and as a function in the Mouse Manager.
This commit is contained in:
parent
1b4e53d06f
commit
87edd6cb94
3 changed files with 30 additions and 1 deletions
|
@ -58,6 +58,8 @@ var Config = new Class({
|
|||
this.inputMouse = GetValue(config, 'input.mouse', true);
|
||||
this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null);
|
||||
|
||||
this.disableContextMenu = GetValue(config, 'disableContextMenu', false);
|
||||
|
||||
// If you do: { banner: false } it won't display any banner at all
|
||||
this.hideBanner = (GetValue(config, 'banner', null) === false);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: 'ef2515e0-70eb-11e7-ad8e-3beabf57a909'
|
||||
build: 'ac7c3390-712c-11e7-94b3-cb219d37da47'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -11,6 +11,11 @@ var MouseManager = new Class({
|
|||
{
|
||||
this.manager = inputManager;
|
||||
|
||||
/**
|
||||
* @property {boolean} capture - If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully.
|
||||
*/
|
||||
this.capture = false;
|
||||
|
||||
this.enabled = false;
|
||||
|
||||
this.target;
|
||||
|
@ -30,16 +35,33 @@ var MouseManager = new Class({
|
|||
this.target = this.manager.game.canvas;
|
||||
}
|
||||
|
||||
if (config.disableContextMenu)
|
||||
{
|
||||
this.disableContextMenu();
|
||||
}
|
||||
|
||||
if (this.enabled)
|
||||
{
|
||||
this.startListeners();
|
||||
}
|
||||
},
|
||||
|
||||
disableContextMenu: function ()
|
||||
{
|
||||
document.body.addEventListener('contextmenu', function (event) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
startListeners: function ()
|
||||
{
|
||||
var queue = this.manager.queue;
|
||||
|
||||
var _this = this;
|
||||
|
||||
var handler = function (event)
|
||||
{
|
||||
if (event.preventDefaulted)
|
||||
|
@ -49,6 +71,11 @@ var MouseManager = new Class({
|
|||
}
|
||||
|
||||
queue.push(event);
|
||||
|
||||
if (_this.capture)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
this.handler = handler;
|
||||
|
|
Loading…
Add table
Reference in a new issue