PIXI.DisplayObjectContainer.ignoreChildInput is a new property. If true then the children will _not_ be considered as valid for Input events. Because this has been applied to DisplayObjectContainer it means it's available in Group, Sprite and any other display level object. Using this boolean you can disable input events for all children in an entire Group, without having to iterate anything or deep-set flags.

InputHandler._pointerOverHandler and _pointerOutHandler have new arguments `silent` - if `true` then they will not dispatch any Signals from the parent Sprite.
This commit is contained in:
photonstorm 2016-06-09 14:32:56 +01:00
parent e8e7e27184
commit fa43bec19f
2 changed files with 22 additions and 5 deletions

View file

@ -470,7 +470,11 @@ Phaser.InputHandler.prototype = {
if (includePixelPerfect === undefined) { includePixelPerfect = true; }
if (!this.enabled || this.sprite.scale.x === 0 || this.sprite.scale.y === 0 || this.priorityID < this.game.input.minPriorityID)
if (!this.enabled ||
this.sprite.scale.x === 0 ||
this.sprite.scale.y === 0 ||
this.priorityID < this.game.input.minPriorityID ||
(this.sprite.parent && this.sprite.parent.ignoreChildInput))
{
return false;
}
@ -926,8 +930,9 @@ Phaser.InputHandler.prototype = {
* @method Phaser.InputHandler#_pointerOverHandler
* @private
* @param {Phaser.Pointer} pointer - The pointer that triggered the event
* @param {boolean} [silent=false] - If silent is `true` then this method will not dispatch any Signals from the parent Sprite.
*/
_pointerOverHandler: function (pointer) {
_pointerOverHandler: function (pointer, silent) {
if (this.sprite === null)
{
@ -953,7 +958,7 @@ Phaser.InputHandler.prototype = {
this._setHandCursor = true;
}
if (sendEvent && this.sprite && this.sprite.events)
if (!silent && sendEvent && this.sprite && this.sprite.events)
{
this.sprite.events.onInputOver$dispatch(this.sprite, pointer);
}
@ -967,8 +972,9 @@ Phaser.InputHandler.prototype = {
* @method Phaser.InputHandler#_pointerOutHandler
* @private
* @param {Phaser.Pointer} pointer - The pointer that triggered the event.
* @param {boolean} [silent=false] - If silent is `true` then this method will not dispatch any Signals from the parent Sprite.
*/
_pointerOutHandler: function (pointer) {
_pointerOutHandler: function (pointer, silent) {
if (this.sprite === null)
{
@ -988,7 +994,7 @@ Phaser.InputHandler.prototype = {
this._setHandCursor = false;
}
if (this.sprite && this.sprite.events)
if (!silent && this.sprite && this.sprite.events)
{
this.sprite.events.onInputOut$dispatch(this.sprite, pointer);
}

View file

@ -22,6 +22,17 @@ PIXI.DisplayObjectContainer = function()
* @readOnly
*/
this.children = [];
/**
* If `ignoreChildInput` is `false` it will allow this objects _children_ to be considered as valid for Input events.
*
* If this property is `true` then the children will _not_ be considered as valid for Input events.
*
* Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down.
* @property {boolean} ignoreChildInput
* @default
*/
this.ignoreChildInput = false;
};