NiftyGui TextField on press ENTER key?

Hello guys, I don’t find any documentation on how to call a controller method on keyUp or on keyDown, the interactive tag only handles mouse clicks.

can anyone shed light on this?

Thx!

or do I have to use the regulat inputListener?
I have no clue.

Not sure if you have any problem with using the event subscriber but you could try this (not sure if it’s outdated):
http://hub.jmonkeyengine.org/forum/topic/getting-text-from-textfield-when-user-presses-return-key/

1 Like

how do i tell what key has been pressed in the textField, I can’t figure it out :confused:
how do i process keyboard inputs?

like if I type

hello [ENTER]

where can I handle the Enter key pressed on textfield?

You know what forget it, it now works, i dunno why it didnt work before :confused: maybe I mistyped the id or something.

1 Like

Instead of creating a new topic I would like to bump this topic.

I am having the same issue as @navycougar.

What is a good way for me to detect that an enter key has been clicked? Currently I’m thinking the <Interact> and OnClickAlternateKey attribute might be useful…

Thanks

@PaladinKetchup said: Instead of creating a new topic I would like to bump this topic.

I am having the same issue as @navycougar.

What is a good way for me to detect that an enter key has been clicked? Currently I’m thinking the <Interact> and OnClickAlternateKey attribute might be useful…

Thanks

hey paladinKetchup,
i remember using this for handling the chat, well i did like untothebreach said, i used an event subscriber on my input control.

[java]@NiftyEventSubscriber(id = “myTextField”)
public void onMyTextFieldInputEvent(final String id,
final NiftyInputEvent event) {
if (NiftyInputEvent.SubmitText.equals(event)) {
// Do Something
}
}[/java]

@navycougar said: hey paladinKetchup, i remember using this for handling the chat, well i did like untothebreach said, i used an event subscriber on my input control.

[java]@NiftyEventSubscriber(id = “myTextField”)
public void onMyTextFieldInputEvent(final String id,
final NiftyInputEvent event) {
if (NiftyInputEvent.SubmitText.equals(event)) {
// Do Something
}
}[/java]

thanks for the reply mate. but where and how do i specify that the “event” was a enter key?

[java]if (NiftyInputEvent.SubmitText.equals(event)) {
// Do Something
}[/java]

this actually is equals to write, in pseudo code :

[java]if(event is Enter){
//do something
}[/java]

Despite this is an old thread, none of the answers worked for me, may be something changed?

only this worked when ENTER key is pressed on textfield:

if(inputEvent.compareTo(NiftyInputEvent.Activate)==0){