1
\$\begingroup\$

I try to learn Scala the fun way, with a little libgdx project.

Now I'm somewhat stuck:

val go = new TextButton("Go", style)
go.addListener(new ClickListener()
{
   override def isPressed() : Boolean =
   {
     Predef.println("isPressed!)
     true
   }
}

This doesn't work, sadly. Not sure why. I tried returning a "java.lang.Boolean" but the compiler doesn't allow for that, saying these would be incompatible types.

On the other hand, the "void"-method of keyTyped works like a charm:

textField.setTextFieldListener(new TextFieldListener()
{
  override def keyTyped(textField: TextField, key: Char)
  {
    textFieldInput = textField.getText()
    Predef.println(textFieldInput) // TODO remove
  }
});

Here when I type something it gets printed to the console.

Any ideas?

That's probably not really related to game-development, still I wasn't sure if another forum would've been a safer bet.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Are you sure this is not working?

I tried to reproduce and it's working just fine. (*)

You wrote that the TextFieldListener is just working fine, so I assume you've set the InputProcessor to the stage, right?

Just in case you did not and did some black magic (or rather for others who might face a similar error):

Gdx.input.setInputProcessor(stage)

(*) I don't know what you try to achieve of course, but: Maybe you rather want "clicked" and "enter" instead?

If this wasn't helpful, please tell me what exactly you want to do. Oh, and sorry, I would've posted this as a comment, but I'm not allowed to, yet -.-

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .