on xenial help sign in
merged with lp:~mzanetti/unity8/findInvisibleChild
4216fadNick Dedekind
tests/utils/modules/Unity/Test/UnityTestCase.qml+21−2
@@ -69,9 +69,28 @@ TestCase {
69 }
69 }
70
70
71
71
72− // Find an object with the given name recursively, starting
72+ // Find an object with the given name in the children tree of "obj"
73− // at the given object "obj"
74 function findChild(obj,objectName) {
73 function findChild(obj,objectName) {
74+ var childs = new Array(0);
75+ childs.push(obj)
76+ while (childs.length > 0) {
77+ if (childs[0].objectName == objectName) {
78+ return childs[0]
79+ }
80+ for (var i in childs[0].children) {
81+ childs.push(childs[0].children[i])
82+ }
83+ childs.splice(0, 1);
84+ }
85+ return undefined;
86+ }
87+
88+ // Find an object with the given name in the children tree of "obj"
89+ // Including invisible children like animations, timers etc.
90+ // Note: you should use findChild if you're not sure you need this
91+ // as this tree is much bigger and might contain stuff that goes
92+ // away randomly.
93+ function findInvisibleChild(obj,objectName) {
75 var childs = new Array(0);
94 var childs = new Array(0);
76 childs.push(obj)
95 childs.push(obj)
77 while (childs.length > 0) {
96 while (childs.length > 0) {