Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED][1.7.10]How to create a text box in GUI


Recommended Posts

private GuiTextField text;

 

public void initGui()
    {
        this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 68, this.height/2-46, 137, 20);
        text.setMaxStringLength(23);
        text.setText("sample text");
        this.text.setFocused(true);
    }

 

protected void keyTyped(char par1, int par2)
    {
        super.keyTyped(par1, par2);
        this.text.textboxKeyTyped(par1, par2);
    }

 

    public void updateScreen()
    {
        super.updateScreen();
        this.text.updateCursorCounter();
    }

 

    public void drawScreen(int par1, int par2, float par3)
    {
        this.drawDefaultBackground();
        this.text.drawTextBox();
        super.drawScreen(par1, par2, par3);
    }

 

    protected void mouseClicked(int x, int y, int btn) {
        super.mouseClicked(x, y, btn);
        this.text.mouseClicked(x, y, btn);
    }

Link to post
Share on other sites

Maybe something like this?

  protected void keyTyped(char par1, int par2)
    {       
        this.text.textboxKeyTyped(par1, par2);         
        if(!( par2== Keyboard.KEY_E  &&  this.text.isFocused())) super.keyTyped(par1, par2);
    }

Link to post
Share on other sites

Maybe something like this?

  protected void keyTyped(char par1, int par2)
    {       
        this.text.textboxKeyTyped(par1, par2);         
        if(!( par2== Keyboard.KEY_E  &&  this.text.isFocused())) super.keyTyped(par1, par2);
    }

THX Works perfectly!!!!

Woking at my first mod, Blocks & Items Revolution : https://github.com/megabitus98/Blocks-Items-Revolution

Link to post
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.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.