mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
The KeyboardPlugin.removeKey
method has a new optional parameter removeCapture
. This will remove any keyboard capture events for the given Key. Fix #5693
This commit is contained in:
parent
841f0fc771
commit
3e1d77ad8f
1 changed files with 18 additions and 2 deletions
|
@ -547,12 +547,14 @@ var KeyboardPlugin = new Class({
|
|||
*
|
||||
* @param {(Phaser.Input.Keyboard.Key|string|number)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value.
|
||||
* @param {boolean} [destroy=false] - Call `Key.destroy` on the removed Key object?
|
||||
* @param {boolean} [removeCapture=false] - Remove this Key from being captured? Only applies if set to capture when created.
|
||||
*
|
||||
* @return {this} This KeyboardPlugin object.
|
||||
*/
|
||||
removeKey: function (key, destroy)
|
||||
removeKey: function (key, destroy, removeCapture)
|
||||
{
|
||||
if (destroy === undefined) { destroy = false; }
|
||||
if (removeCapture === undefined) { removeCapture = false; }
|
||||
|
||||
var keys = this.keys;
|
||||
var ref;
|
||||
|
@ -584,6 +586,11 @@ var KeyboardPlugin = new Class({
|
|||
{
|
||||
ref.plugin = null;
|
||||
|
||||
if (removeCapture)
|
||||
{
|
||||
this.removeCapture(ref.keyCode);
|
||||
}
|
||||
|
||||
if (destroy)
|
||||
{
|
||||
ref.destroy();
|
||||
|
@ -600,11 +607,15 @@ var KeyboardPlugin = new Class({
|
|||
* @since 3.24.0
|
||||
*
|
||||
* @param {boolean} [destroy=false] - Call `Key.destroy` on each removed Key object?
|
||||
* @param {boolean} [removeCapture=false] - Remove all key captures for Key objects owened by this plugin?
|
||||
*
|
||||
* @return {this} This KeyboardPlugin object.
|
||||
*/
|
||||
removeAllKeys: function (destroy)
|
||||
removeAllKeys: function (destroy, removeCapture)
|
||||
{
|
||||
if (destroy === undefined) { destroy = false; }
|
||||
if (removeCapture === undefined) { removeCapture = false; }
|
||||
|
||||
var keys = this.keys;
|
||||
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
|
@ -615,6 +626,11 @@ var KeyboardPlugin = new Class({
|
|||
{
|
||||
keys[i] = undefined;
|
||||
|
||||
if (removeCapture)
|
||||
{
|
||||
this.removeCapture(key.keyCode);
|
||||
}
|
||||
|
||||
if (destroy)
|
||||
{
|
||||
key.destroy();
|
||||
|
|
Loading…
Add table
Reference in a new issue