mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-20 04:09:45 +00:00
3 files changed
+26
-9
No files matched your search
@@ -2,4 +2,4 @@ mc_version=1.7.10
|
||||
forge_version=10.13.4.1614-1.7.10
|
||||
ccl_version=1.1.3.138
|
||||
ccc_version=1.0.7.+
|
||||
mod_version=2.0.0-pre-8-GTNH
|
||||
mod_version=2.0.0-pre-9-GTNH
|
||||
@@ -6,7 +6,7 @@ import org.lwjgl.input.Keyboard;
|
||||
|
||||
public abstract class TextField extends Widget
|
||||
{
|
||||
protected final GuiTextField field;
|
||||
protected GuiTextField field;
|
||||
|
||||
private static final int maxSearchLength = 256;
|
||||
|
||||
@@ -15,11 +15,15 @@ public abstract class TextField extends Widget
|
||||
|
||||
private boolean previousKeyboardRepeatEnabled;
|
||||
|
||||
public TextField(String ident) {
|
||||
identifier = ident;
|
||||
protected void initInternalTextField() {
|
||||
field = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 0, 0);
|
||||
field.setMaxStringLength(maxSearchLength);
|
||||
field.setCursorPositionZero();
|
||||
}
|
||||
|
||||
public TextField(String ident) {
|
||||
identifier = ident;
|
||||
initInternalTextField();
|
||||
// Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
@@ -27,15 +31,29 @@ public abstract class TextField extends Widget
|
||||
return focused() ? 0xFFE0E0E0 : 0xFF909090;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey) {
|
||||
protected void setDimensionsAndColor() {
|
||||
field.xPosition = this.x + 2;
|
||||
field.yPosition = this.y + 2;
|
||||
field.width = this.w - 4;
|
||||
field.height = this.h - 4;
|
||||
field.setTextColor(getTextColour());
|
||||
}
|
||||
|
||||
field.drawTextBox();
|
||||
@Override
|
||||
public void draw(int mousex, int mousey) {
|
||||
try {
|
||||
setDimensionsAndColor();
|
||||
field.drawTextBox();
|
||||
} catch(NullPointerException npe) {
|
||||
// Hack to deal with a null font renderer... recreate the field and it should work
|
||||
GuiTextField oldField = field;
|
||||
|
||||
initInternalTextField();
|
||||
setDimensionsAndColor();
|
||||
|
||||
field.setText(oldField.getText());
|
||||
field.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,9 +12,8 @@ import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
||||
public class OptionTextField extends Option
|
||||
{
|
||||
private boolean focused = false;
|
||||
private final TextField textField = new TextField("")
|
||||
private TextField textField = new TextField("test")
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
if(focused() && isValidValue(text()))
|
||||
|
||||
Reference in new issue
Block a user