How to cancel element focus

Hi all,
is there any way i can blur element? or how im supposed to switch focus from chat to gameplay ?
[java]
chatBox = new ChatBox(screen, new Vector2f(15f, height - 315), new Vector2f(400f, 300f)) {
@Override
public void onSendMsg(String msg) {
ZoneOfUprisingClient game = ZoneOfUprisingClient.instance;
if(game.isConnected()) {
game.client.send(new ChatMessage(msg));
}
// how to blur whole gui?
}
};
[/java]

@Ascaria said: Hi all, is there any way i can blur element? or how im supposed to switch focus from chat to gameplay ? [java] chatBox = new ChatBox(screen, new Vector2f(15f, height - 315), new Vector2f(400f, 300f)) { @Override public void onSendMsg(String msg) { ZoneOfUprisingClient game = ZoneOfUprisingClient.instance; if(game.isConnected()) { game.client.send(new ChatMessage(msg)); } // how to blur whole gui? } }; [/java]

There is… lemme check one of my projects to see how =)

I believe you just call:

[java]
screen.resetTabFocusElement();
[/java]

This does not work for me:
[java]
AppSettings settings = ZoneOfUprisingClient.instance.getContext().getSettings();
int height = settings.getHeight();

    chatBox = new ChatBox(screen, "HudChat", new Vector2f(15f, height - 315), new Vector2f(400f, 300f)) {
        @Override
        public void onSendMsg(String msg) {
            ZoneOfUprisingClient game = ZoneOfUprisingClient.instance;
            if(game.isConnected()) {
                game.client.send(new ChatMessage(msg));
            }
            screen.resetTabFocusElement();
        }
    };
    chatBox.setGlobalAlpha(0.8f);
    chatBox.setSendKey(KeyInput.KEY_RETURN);
    chatBox.setIsResizable(false);
    screen.addElement(chatBox);

[/java]

so i tried to get exactly chatbox’s text field (hard because its private) and then do
[java]
public void onSendMsg(String msg) {
ZoneOfUprisingClient game = ZoneOfUprisingClient.instance;
if(game.isConnected()) {
game.client.send(new ChatMessage(msg));
}
TextField chatText = (TextField)screen.getElementById(“HudChat:ChatInput”);
chatText.resetTabFocus();
}
[/java]
and this works fine :slight_smile:

1 Like