Mercurial > projects > dynamin
changeset 59:d3ba5d4a3a27
Add Control.findAncestor
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 08 Aug 2009 18:02:43 -0500 |
parents | 712ea1ea845a |
children | cf7c5f968306 |
files | dynamin/gui/control.d |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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. */