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

Allow passing varargs from vgui.Create to Panel:Init #2176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luca1197
Copy link

@luca1197 luca1197 commented Dec 20, 2024

This PR makes it possible to pass varargs from vgui.Create to Panel:Init for custom (user-created) panels.

Passing arguments to Panel:Init can be quite useful in a few cases, generally when the goal is to allow changing some behavior in the Init function without it being really necessary to separate these different behaviors into individual functions.

It would be possible to define a custom init function for the panel and call that after vgui.Create, but I don't see a reason why a cleaner solution like this shouldn't exist.

Thanks :)

@darkfated
Copy link
Contributor

A conditional constructor that allows arguments to be passed during initialization... In the context of GLua, this can cause confusion, because it is not known which of the ui elements has support for this, and the elements for which things we transmit. It is better to adhere to encapsulation, and formalize everything through methods. A useless thing

@luca1197
Copy link
Author

luca1197 commented Jan 3, 2025

I see what you're saying, but in my opinion the goal should be to allow different implementation "styles" for the many possible use-cases. If you prefer not to make use of it, that's totally fine, but the option remains available for those who do. Especially since this is just a minor change that applies only to panels that explicitly choose to make use of it.

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

Successfully merging this pull request may close these issues.

2 participants