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

Suggestion: Add callback function to Gui#update method #820

Open
cameronbrown5 opened this issue Jan 9, 2024 · 1 comment
Open

Suggestion: Add callback function to Gui#update method #820

cameronbrown5 opened this issue Jan 9, 2024 · 1 comment

Comments

@cameronbrown5
Copy link

cameronbrown5 commented Jan 9, 2024

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.

@stefvanschie
Copy link
Owner

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.

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

2 participants