getChildComponents returns all descendents
-
.getChildComponentsdoesn't just return direct children (as the API doc suggests) it returns every descendent down the chain. I can see this being very useful, but I only want the direct children.For now I'm looping through the list it returns and manually checking the parent component but I think this should be fixed. Probably behind a preprocessor for those who have been using it.
-
@David-Healey or perhaps adding an optional parameter
bool recursive? -
Changing the function signature is a breaking change too, but I think a preprocessor is weird for that, just add another function. The hard thing is to come with a non-weird name for it, my best attempt is
getDirectChildComponents() -
@Christoph-Hart so why not with a bool recursive if you make a new one? so it can do both until we can safely retire the old one in a few years...
-
@Christoph-Hart @ustk How about two new functions:
getDirectChildComponents() getRecursiveChildComponents()and a nice loud
deprecatedconsole message on the existinggetChildComponents()function?Seems better to eventually end up with non-confusing function names rather than carry the confusing one on forever?
-
Or why not just change the function signature for
getChildComponents()as a breaking change?It would fail to compile, so it would be a nice loud error with a very easy fix for each dev currently using it.
-
Or just make the function do what the documentation says it should do :p Also a breaking change but probably one that won't affect many people.
Then add a new function to get all descendents.
-
@David-Healey If you're making a breaking change, why not roll the optional boolean in there too?
Same effect as without it (breaks compiling) plus a minimal doc change for a nice tidy, truthful function.
-
@David-Healey Where are you using
getChildComponents()? On a Script object (ScriptButton, etc)?Because
ContainerChildalready hasgetAllComponents()here but nothing else has it. -
@dannytaurus In the script I'm currently working on I'm using it with a panel.
-
