IF icon indicating copy to clipboard operation
IF copied to clipboard

Suggestion: Add callback function to Gui#update method

Open cameronbrown5 opened this issue 2 years ago • 1 comments

Hi there, I'm currently working on a gui and I'd like to add navigation buttons that will appear only if there's a page to go to. Right now, I have to have click functions on the items that will either add or remove the item depending on which page you're on. If we could have a callback function that is called when the gui is updated, it would simplify this to adding or removing buttons whenever I update the panel for the new page. This also would add a ton of opportunity for things like animations while in guis.

I'm willing to fork and create a pull request for this if you'd like.

cameronbrown5 avatar Jan 09 '24 01:01 cameronbrown5

To my understanding you would like to have some kind of Gui#setOnUpdate(Runnable) method for which the provided Runnable is ran every time the gui is updated. Then you'd change the navigation in that Runnable. I personally don't see the utility in such a method for your purposes. Currently you'd update the navigation whenever the page is swapped, generally whenever the player clicks a navigation button. With your proposed solution, you'd have the same kind of code, but now in a different place. I personally don't think that makes enough of a difference to warrant this addition. Also, in my opinion it's easier to make the items/panes for the navigation invisible if you can't go in that direction. This probably already helps make your code easier.

stefvanschie avatar Jan 30 '24 18:01 stefvanschie

Closing this because of inactivity. If you have a good reason why your suggestion would significantly aid development, please reply to this and the issue can be reopened.

stefvanschie avatar Sep 07 '25 19:09 stefvanschie