#FEATURE by cg
class: AbstractHierarchicalItem
added: #recursiveDetect:skipIf:skipChildrenIf:
--- a/AbstractHierarchicalItem.st Tue May 07 13:13:22 2019 +0200
+++ b/AbstractHierarchicalItem.st Tue May 07 13:14:22 2019 +0200
@@ -2527,6 +2527,22 @@
^ nil
!
+recursiveDetect:aOneArgBlock skipIf:elementCheck skipChildrenIf:childrenCheck
+ "recursive find the first child, for which evaluation
+ of the block returns true; if none, nil is returned.
+ Warning: this only searches in already visible child elements
+ i.e. any collapsed items are not searched."
+
+ self
+ recursiveDo:[:aChild|
+ (aOneArgBlock value:aChild) ifTrue:[^ aChild]
+ ]
+ skipIf:elementCheck skipChildrenIf:childrenCheck.
+ ^ nil
+
+ "Created: / 07-05-2019 / 13:14:03 / Claus Gittinger"
+!
+
recursiveDetectLast:aBlock
"recursive find the last child, for which evaluation of the block returns true;
if none does so, nil is returned.