Jump to content

Make EditBox active and focused when screen opened [1.19.2] [SOLVED]


Recommended Posts

Hi! I have screen that has some edit boxes on it. When player opens the screen I would like the first edit box be active so I could start typing in that without having to click on it before.

public void init() {

  TBDisplay = new EditBox(this.font, this.leftPos + 7, this.topPos + 11, 150, 20, Component.literal(""));
  //Initialize other components

  //Trying to set the focus
  TBDisplay.active = true;

Setting the focus after initializing this and all other components on the screen highlights the edit box, but I still have to click on it before I can write something in it. How to make the edit box focused and writable without clicking on it? Thanks. 

Edited by RInventor7
Link to comment
Share on other sites

  • RInventor7 changed the title to Make EditBox active and focused when screen opened [1.19.2] [SOLVED]

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.

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.


  • Create New...

Important Information

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