Add a warning when using plain Container, as many users seem to misunderstand what this is.

This commit is contained in:
Juan Linietsky 2019-03-03 16:00:29 -03:00
parent 9357d691a2
commit 6b8b1cabae
2 changed files with 15 additions and 0 deletions

View file

@ -169,6 +169,19 @@ void Container::_notification(int p_what) {
} }
} }
String Container::get_configuration_warning() const {
String warning = Control::get_configuration_warning();
if (get_class() == "Container" && get_script().is_null()) {
if (warning != String()) {
warning += "\n";
}
warning += TTR("Container by itself serves no purpose unless a script configures it's children placement behavior.\nIf you dont't intend to add a script, then please use a plain 'Control' node instead.");
}
return warning;
}
void Container::_bind_methods() { void Container::_bind_methods() {
ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children); ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children);

View file

@ -57,6 +57,8 @@ public:
void fit_child_in_rect(Control *p_child, const Rect2 &p_rect); void fit_child_in_rect(Control *p_child, const Rect2 &p_rect);
virtual String get_configuration_warning() const;
Container(); Container();
}; };