Jump to content

[SOLVED] [1.6.4] Text Box Gui element not registering my click at the right spot


osum4est

Recommended Posts

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);
}


}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.