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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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