Jump to content

button.input.enabled = false not working


CraigH23
 Share

Recommended Posts

Hi,

I have a button which calls a function:

button = game.add.button(0, 0, 'button', function);

when the button is clicked and the function is called I want to disable the button:

button.input.enabled = false;

if I print button.inputEnabled to the console, I get the expected value but the button is still clickable. I have also tried setting button.inputEnabled = false; but have the same issue.

Thanks in advance,

Craig. 

Link to comment
Share on other sites

  • 1 year later...

I figured out that I'm able to disable the input only if I set the property inputEnabled to FALSE inside the callback method.

So for example

let button: Phaser.Button = new Phaser.Button(this.game, this.game.world.centerX, this.game.world.height - 45,'key', null, this,
'frame1','frame2','frame3','frame4');

button.inputEnabled = false;
button.onInputUp.add(this.onClick2);

So in this case it will trigger the method onClick2 always. 
But then if I set inputEnabled=FALSE inside that method, then it actually disables the input. Is this normal behaviour?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...