Hi,
For my game I need a chat, so I made a label and an textfield control. The textfield control get’s disabled when the screen is activated (otherwise Nifty sets focus on the textfield, and I don’t use a cursor in my game so I couldn’t get off of the focus and thus I wouldn’t be able to move my character). So when I press enter the textfield get’s activated and focus is set to the textfield, but now the problem comes… when I press enter again, the message entered in the textfield, is send and the textfield should be set to disabled again… this works, but only for like half a second (It blinks from red to gray to red again). So is there a way I can remove focus from the textfield control?
sendMessage get’s called when enter is pressed
[java] public static void sendMessage() {
textMessage.enable();
chatMessage = textMessage.getText();
if (chatMessage.trim().length() != 0) {
ClientHandler.sendChatMessage(chatMessage);
textMessage.setText("");
textMessage.disable();
} else {
textMessage.setFocus();
}
}
[/java]
I’m on a deadline (almost literally), and I haven’t downloaded the new updates, as I’m scared there could be a change in one of the things I use and I won’t be able to fix it in time.
I’m not sure how old your Nifty is but this seems to work with the latest from SVN. I’ve tried your code with a textfield and it looks good to me. The field stays disabled here so I’m not sure whats the problem. Probably a bug in your old version or maybe there is something else. You’re not enabling something else or the textfield again from somewhere else?