Search in sources :

Example 1 with FocusableGuiElement

use of io.xol.chunkstories.api.gui.FocusableGuiElement in project chunkstories by Hugobros3.

the class LoginPrompt method handleInput.

@Override
public boolean handleInput(Input input) {
    if (input.equals("exit"))
        autologin = false;
    else if (input.equals("enter"))
        connect();
    else if (input.equals("tab")) {
        int shift = gameWindow.getInputsManager().getInputByName("shift").isPressed() ? -1 : 1;
        int i = this.elements.indexOf(this.focusedElement);
        GuiElement elem = null;
        while (elem == null || !(elem instanceof FocusableGuiElement)) {
            i += shift;
            if (i < 0)
                i = this.elements.size();
            if (i >= this.elements.size())
                i = 0;
            elem = this.elements.get(i);
        }
        if (elem != null)
            this.focusedElement = (FocusableGuiElement) elem;
    }
    return super.handleInput(input);
}
Also used : GuiElement(io.xol.chunkstories.api.gui.GuiElement) FocusableGuiElement(io.xol.chunkstories.api.gui.FocusableGuiElement) FocusableGuiElement(io.xol.chunkstories.api.gui.FocusableGuiElement)

Aggregations

FocusableGuiElement (io.xol.chunkstories.api.gui.FocusableGuiElement)1 GuiElement (io.xol.chunkstories.api.gui.GuiElement)1