# HG changeset patch # User Jordan Miner # Date 1249788734 18000 # Node ID aa7eafe2865d4b4e9bb901c356bb15126d022f4c # Parent 84beb40c1665ee5971fd731eafc6b979a69ec7c6 Add setTabOrder() diff -r 84beb40c1665 -r aa7eafe2865d dynamin/gui/control.d --- 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; }); +} +