Hi!
I have a problem with the GuiTextField. I'm trying to show a GUI to enter a String. But my GuiTextField does not show in the GUI when I open it in the game. Here is my code:
[embed=425,349]public class CustomGUI extends GuiContainer {
public CustomGUI(Container inventorySlotsIn) {
super(inventorySlotsIn);
}
private int distanceFromLeftSide;
private GuiTextField idTextField;
@Override
public void initGui() {
super.initGui();
this.distanceFromLeftSide = (this.width - 256) / 2;
//net.minecraft.client.gui.GuiTextField.GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height)
this.idTextField = new GuiTextField(1, this.fontRendererObj, this.distanceFromLeftSide + 10, 30, 236, 15);
this.idTextField.setEnableBackgroundDrawing(false);
this.idTextField.setMaxStringLength(40);
this.idTextField.setVisible(true);
this.idTextField.setEnabled(true);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
// this.drawString(this.fontRendererObj, "lalala",
// this.distanceFromLeftSide + 10, 30, 0x000000);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
this.mc.getTextureManager().bindTexture(new ResourceLocation("textures/gui/demo_background.png"));
this.drawTexturedModalRect(this.distanceFromLeftSide, 20, 0, 0, 256, 256);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
this.idTextField.drawTextBox();
}
@Override
public boolean doesGuiPauseGame() {
return true;
}
}
[/embed]
Does anybody have any idea why this only shows the GUI background and not the GuiTextField?
Any help would be very appreciated.
Thanks
Mike