# HG changeset patch # User Jordan Miner # Date 1249772563 18000 # Node ID d3ba5d4a3a27444f1225830dead25d61ffc790f6 # Parent 712ea1ea845a9694031a9bd39fbef4b9db9c75df Add Control.findAncestor diff -r 712ea1ea845a -r d3ba5d4a3a27 dynamin/gui/control.d --- a/dynamin/gui/control.d Sat Aug 08 17:16:11 2009 -0500 +++ b/dynamin/gui/control.d Sat Aug 08 18:02:43 2009 -0500 @@ -464,6 +464,21 @@ } /** + * Calls the specified delegate with each of this control's ancestors, + * starting with its parent and moving up. Returns the first ancestor + * that the delgate returns true for. If none are found, returns null. + */ + Container findAncestor(bool delegate(Container) dg) { + Container anc = parent; + while(anc) { + if(dg(anc)) + return anc; + anc = anc.parent; + } + return null; + } + + /** * Gets or sets whether is control is visible. The default is true, except * on top-level windows. */