Posted February 5, 201411 yr I have made a GUI with a textbox, but when I click it, it doesn't activate! But, if I click it's location from the actual size of the window, so subtracting GuiTop and GuiLeft, it will activate. I tried adding GuiTop and left to the click but it still won't work. Any Help? Code: package skillcraft.client.interfaces; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import tileentities.TileEntityRunetable; public class GuiRunetable extends GuiContainer { int testX = 25; int testY = 25; private TileEntityRunetable runetable; GuiTextField textFieldName; public GuiRunetable(InventoryPlayer invPlayer, TileEntityRunetable runetable) { super(new ContainerRunetable(invPlayer, runetable)); this.runetable = runetable; xSize = 176; ySize = 191; } @Override public void initGui() { super.initGui(); textFieldName = new GuiTextField(fontRenderer, 68, 5, 100, 15); textFieldName.setMaxStringLength(20); textFieldName.setFocused(false); } private static final ResourceLocation texture = new ResourceLocation("skillcraft", "textures/gui/runetablegui.png"); @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } @Override public void updateScreen() { textFieldName.updateCursorCounter(); } @Override protected void drawGuiContainerForegroundLayer(int x, int y) { fontRenderer.drawString("Rune Table", 8, 8, 0x404040); int[] error = runetable.runeHandler.errorCheck(); if (error[0] == 1) { fontRenderer.drawString("You maxed out this rune!", 26, 67, 0xFF3300); } else if (error[0] == 2) { fontRenderer.drawString("Can't add this rune to this item!", 10, 67, 0xFF3300); } else if (error[0] == 3) { fontRenderer.drawString("You must have " + error[1] + " levels!", 28, 67, 0xFF3300); } textFieldName.drawTextBox(); } @Override protected void keyTyped(char key, int par2) { //if (!textFieldName.isFocused()) //{ super.keyTyped(key, par2); //} textFieldName.textboxKeyTyped(key, par2); //if (runetable.getStackInSlot(2) != null) //{ /// runetable.nameTool(textFieldName.getText()); ///} switch (key) { case 'w': testY--; break; case 'a': testX--; break; case 's': testY++; break; case 'd': testX++; break; case 'o': System.out.println(testX + ", " + testY); } } public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); textFieldName.mouseClicked(i, j, k); } }
February 7, 201411 yr Author In the mouseClicked method. Is it because it isn't going to the server or something? public void mouseClicked(int i, int j, int k) { super.mouseClicked(i, j, k); textFieldName.mouseClicked(i + guiLeft, j + guiTop, k); } When I do this I cannot even find where I'm supposed to click. So guiLeft and top are definately not 0
February 7, 201411 yr Author Figured it out! Such a simple error. Instead of adding guiLeft and top onto the mouse points you have to subract them! Should of realized that. Well, thanks for your help! I really appreciated it!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.