Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Text fields #144

Open
seasonedfish opened this issue Dec 5, 2021 · 4 comments
Open

Docs: Text fields #144

seasonedfish opened this issue Dec 5, 2021 · 4 comments

Comments

@seasonedfish
Copy link

Hello, I would like to use this library to create a text field for my mod, but the wiki page for this is empty. I would appreciate it if a guide were added on how to create text fields.

@nullium21
Copy link

Here's a minimal example for it (excluding imports):

public class TextFieldTest extends LightweightGuiDescription {
  public TextFieldTest() {
    WGridPanel root = new WGridPanel();
    setRootPanel(root);

    WTextField field = new WTextField();
    field.setHost(this); // input won't work if the 'host' is not set
    add(field, 0, 0, 5, 1); // height can be any, WTextField#setSize overrides any given y value with 20px

    root.validate(this);
  }

  public static CottonClientScreen createScreen() {
    return new CottonClientScreen(new TextFieldTest());
  }
}

But beware it doesn't support multiline input or output if that's what you need. (see #158)

@Juuxel
Copy link
Member

Juuxel commented Apr 21, 2022

field.setHost(this); // input won't work if the 'host' is not set

FYI, this line isn't needed if you have the root.validate(this) call as expected (the host is set there).

@seasonedfish
Copy link
Author

Thanks!

@seasonedfish
Copy link
Author

Oh wait, the wiki page is still empty: https://github.com/CottonMC/LibGui/wiki/Text-fields
@Juuxel could you update it? It says I don't have permission to update it.

@seasonedfish seasonedfish reopened this Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants