enchanced optionmenu

This commit is contained in:
yugecin
2017-01-29 11:28:24 +01:00
parent 90f764c5bb
commit 7e135550e0
9 changed files with 625 additions and 199 deletions

View File

@@ -96,16 +96,7 @@ public class TextField extends Component {
}
public void render(Graphics g) {
if (lastKey != -1) {
if (displayContainer.input.isKeyDown(lastKey)) {
if (repeatTimer < System.currentTimeMillis()) {
repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
keyPressed(lastKey, lastChar);
}
} else {
lastKey = -1;
}
}
performKeyRepeat();
Rectangle oldClip = g.getClip();
g.setWorldClip(x,y,width, height);
@@ -145,6 +136,20 @@ public class TextField extends Component {
g.setClip(oldClip);
}
public void performKeyRepeat() {
if (lastKey == -1) {
return;
}
if (!displayContainer.input.isKeyDown(lastKey)) {
lastKey = -1;
return;
}
if (repeatTimer < System.currentTimeMillis()) {
repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
keyPressed(lastKey, lastChar);
}
}
public String getText() {
return value;
}