boolean handled = false;
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
Keyboard.enableRepeatEvents(false);
} else if (getScreen() != null) {
boolean tab = Keyboard.getEventKey() == Keyboard.KEY_TAB;
TextField focusedTF = null;
ConcurrentSkipListMap<Integer, TextField> tabIndexMap = tab ? new ConcurrentSkipListMap<Integer, TextField>() : null;
for (Widget widget : screen.getAttachedWidgets(true)) {
if (widget instanceof Control) {
Control control = (Control) widget;
if (control.isFocus()) {
if (Keyboard.getEventKeyState()) {
handled = control.onKeyPressed(org.spoutcraft.api.gui.Keyboard.getKey(Keyboard.getEventKey()));
} else {
handled = control.onKeyReleased(org.spoutcraft.api.gui.Keyboard.getKey(Keyboard.getEventKey()));
}
}
if (handled) {
break;
}
}
if (!Keyboard.getEventKeyState()) {
break;
}
if (widget instanceof TextField) {
TextField tf = (TextField) widget;
// Handle tabbing get all textfields of this screen and start looking for the next bigger tab-index
if (tab) {
if (tf.isFocus()) {
focusedTF = tf;
}
tabIndexMap.put(tf.getTabIndex(), tf);
// Pass typed key to text processor
} else if (tf.isEnabled() && tf.isFocus()) {
if (tf.getTextProcessor().handleInput(Keyboard.getEventCharacter(), Keyboard.getEventKey())) {
tf.onTextFieldChange();
ScheduledTextFieldUpdate updateThread = null;
if (scheduledTextFieldUpdates.containsKey(tf)) {
updateThread = scheduledTextFieldUpdates.get(tf);
if (updateThread.isAlive()) {
updateThread.delay();