comparison dynamin/gui/control.d @ 64:aa7eafe2865d

Add setTabOrder()
author Jordan Miner <jminer7@gmail.com>
date Sat, 08 Aug 2009 22:32:14 -0500
parents cf7c5f968306
children 419e38206522
comparison
equal deleted inserted replaced
63:84beb40c1665 64:aa7eafe2865d
675 void repaint() { 675 void repaint() {
676 repaint(Rect(0, 0, width, height)); 676 repaint(Rect(0, 0, width, height));
677 } 677 }
678 } 678 }
679 679
680 /**
681 * Sets the tabIndex of each control to be subsequent numbers. The first control
682 * will have an index of startIndex.
683 */
684 void setTabOrder(Control[] controls...) {
685 setTabOrder(0, controls);
686 }
687 /// ditto
688 void setTabOrder(int startIndex, Control[] controls...) {
689 foreach(c; controls)
690 c.tabIndex = startIndex++;
691 }
692
680 unittest { 693 unittest {
681 Control c = new Control; 694 auto c1 = new Control;
682 c.withGraphics((Graphics g) { g.source = Color.Blue; }); 695 auto c2 = new Control;
696 auto c3 = new Control;
697
698 // test setTabOrder()
699 setTabOrder(c1, c2, c3);
700 assert(c1.tabIndex == 0);
701 assert(c2.tabIndex == 1);
702 assert(c3.tabIndex == 2);
703
704 c1.withGraphics((Graphics g) { g.source = Color.Blue; });
683 } 705 }
684 706