Best way to handle nifty textfield focus in a HUD

I don’t know if this is the best forum for this, it may be better to use some Nifty forum but I’ve used this forum before and everyone seemed really helpful.

I’m using a Nifty screen as the HUD for my game and the hud has a textfield in it. The problem is that the textfield has default focus and taking all my keyboard input and theres no way to unfocus it. Ideally I want it to lose focus if i just click somewhere else. I’ve been reading the Nifty manual trying to figure what I need to do but the way its broken up is really confusing. I’m using XML to create the screen so I’m not sure how I should go about this. I know I need to do something with input handling of mouse events and then do something to disable the textfield’s focus but this is my first thing using JME and Nifty so I’m a bit lost when it comes to some things.

I wanted to ask some more specific questions but I realized I don’t even know what questions to ask. I think I’m just having trouble figuring out where how to begin. Thats what I need help with the most. I know i have to use input handing somehow.

Basically I just want to know:
How do I make a textfield not focused by default when its created with xml?
Figured it out using screen.getFocusHandler().resetFocusElements() in bind method of screen controller

How do I unfocus that textfield when I click anywhere else?

I would go with an AppState that has input listener.

I’m not sure does Nifty component actually capture the input when a Nifty component is clicked (I think yes). This is what you want at least. Otherwise you need to determine was the click on a Nifty component or not. If not, then just defocus the Nifty component with the code you already figured out.