Mercurial > projects > dynamin
changeset 64:aa7eafe2865d
Add setTabOrder()
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 08 Aug 2009 22:32:14 -0500 |
parents | 84beb40c1665 |
children | 7c5c50a06ffe |
files | dynamin/gui/control.d |
diffstat | 1 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dynamin/gui/control.d Sat Aug 08 20:35:48 2009 -0500 +++ b/dynamin/gui/control.d Sat Aug 08 22:32:14 2009 -0500 @@ -677,8 +677,30 @@ } } -unittest { - Control c = new Control; - c.withGraphics((Graphics g) { g.source = Color.Blue; }); +/** + * Sets the tabIndex of each control to be subsequent numbers. The first control + * will have an index of startIndex. + */ +void setTabOrder(Control[] controls...) { + setTabOrder(0, controls); +} +/// ditto +void setTabOrder(int startIndex, Control[] controls...) { + foreach(c; controls) + c.tabIndex = startIndex++; } +unittest { + auto c1 = new Control; + auto c2 = new Control; + auto c3 = new Control; + + // test setTabOrder() + setTabOrder(c1, c2, c3); + assert(c1.tabIndex == 0); + assert(c2.tabIndex == 1); + assert(c3.tabIndex == 2); + + c1.withGraphics((Graphics g) { g.source = Color.Blue; }); +} +