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

[1.16.x] Updating Widgets in GUI


urbanxx001
 Share

Recommended Posts

According to several sources, it's difficult to update widgets when you're not directly clicking/interacting with them. In my case I'd like to change the text displayed by buttons. I've considered a few solutions. One is to call drawing events in GuiScreenEvent to get the widgets and replace them. However these events are only called when the screen is instantiated. Another is to use the updateScreen() method in the custom screen class, however I can't seem to find it so I believe I'm not calling it correctly or it's deprecated. Finally I could manually close and reopen the screen with updated fields for the buttons, but this seems expensive. 

Edited by urbanxx001
Link to comment
Share on other sites

2 hours ago, urbanxx001 said:

The condition is from a scrollbar. I can do changes there, however I don't what actual methods exist to either remove or update the buttons.

You could perhaps store the buttons you want to change in an extra list, and then just iterate through that list and update the buttons when you want to perform the update.

  • Like 1
Link to comment
Share on other sites

9 hours ago, vemerion said:

iterate through that list and update the buttons when you want to perform the update.

Yeah toggling the visibility is an option. However this is usually only possible by clicking on the button, which can't be done in this case. Now that I think about it, the game rule menu for creating a world has scrolling buttons, I’ll take a look there.

 

Edit: ok I didn't realize you could access the widgets with  this.field_230710_m_ ..smh these auto-generated names.

Edited by urbanxx001
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
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.

 Share



×
×
  • Create New...

Important Information

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