Posted November 17, 20204 yr 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 November 17, 20204 yr by urbanxx001
November 17, 20204 yr What's the condition of changing the texts? If it's your own screen I think Screen#tick might be what are you looking for. Edited November 17, 20204 yr by poopoodice
November 17, 20204 yr Author 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. Edited November 17, 20204 yr by urbanxx001
November 17, 20204 yr 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.
November 17, 20204 yr Author 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 November 17, 20204 yr by urbanxx001
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.