Jump to content

GuiTextField Coordinates


Stjubit

Recommended Posts

Hello everyone,

 

I really don't get it, how a GuiTextField is aligned in a GuiContainer.

I have overwritten the drawGuiContainerBackgroundLayer to display my Background Image as followed:

 

 

@Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        mc.renderEngine.bindTexture(resourceLocation);

        GL11.glColor4f(1.0f,1.0f,1.0f,1.0f);

        int bgX = width/2-128;
        int bgY = height/2-28;

        this.drawTexturedModalRect(bgX, bgY, 0, 0, 256, 57);
    }

 

 

 

Background-Image:

uQbazEM.png

 

So the Background-Image is centered in Minecraft, as I wanted.

 

Now the problem:

When I initialize my GuiTextField like so:

tfFrequency = new GuiTextField(fontRendererObj, 0,0,tfWidth,tfHeight);

 

...the TextField is anywhere. Here is a Screenshot as it looks In-Game:

3Wyuxnr.png

 

So the coordinates 0/0 are up there. Why? Where do the coordinates of a GuiTextField start?

 

Thanks for every help and sorry for my bad english,

Julian

Link to comment
Share on other sites

Yeah, that's exactly what I thought, too, but if you would have read my Thread, you would know, that that's not the case. Please give a useful answer, or let it be.

 

Why is 0/0 not in the left top of the Minecraft-Screen or in the left top of the GUI-Background? It's just anywhere?!

 

With best regards,

Julian

Link to comment
Share on other sites

Hello, thanks for your answer.

 

I use Forge-Version 10.13.4.1448 for Minecraft 1.7.10 ;)

 

I just figured out, that when I overwrite the method "drawScreen()" in my GuiContainer-class and draw the GuiTextField in that method instead of drawing it in the "drawGuiContainerForegroundLayer"-method, the coordinates are right and everything is perfect. But why is 0/0 in the drawGuiContainerForegroundLayer-method on another place than 0/0 in the drawScreen-method?

 

Thanks for your answer!

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.