2007-07-13 William Holmes <billholmes54@gmail.com>
authorAndreia Gaita <avidigal@novell.com>
Fri, 13 Jul 2007 18:09:37 +0000 (18:09 -0000)
committerAndreia Gaita <avidigal@novell.com>
Fri, 13 Jul 2007 18:09:37 +0000 (18:09 -0000)
* Control.cs: Changing logic in FindFlatForward and
  FindFlatBackward to handle multiple Controls with
  the same TabIndex.
  This fixes bug 81687.

svn path=/trunk/mcs/; revision=81957

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs

index 4010e9b76b2397f4da9be1f2d945a3684fd89e6c..8e119d47d71036405114d3daaba7c1bcf023756f 100644 (file)
@@ -1,3 +1,10 @@
+2007-07-13     William Holmes <billholmes54@gmail.com> 
+
+       * Control.cs: Changing logic in FindFlatForward and 
+         FindFlatBackward to handle multiple Controls with 
+         the same TabIndex.  
+         This fixes bug 81687.
+
 2007-07-13  Jonathan Pobst  <monkey@jpobst.com>
 
        * OSFeature.cs: Enable IsPresent.
index f54a53c1d21e43eff6ded0e7ada93615f418b1f8..2d16b5b2b1e01b1df7be63f0b64d2582d02ecc92 100644 (file)
@@ -1544,9 +1544,11 @@ namespace System.Windows.Forms
                        Control found;
                        int     index;
                        int     end;
+                       bool hit;
 
                        found = null;
                        end = container.child_controls.Count;
+                       hit = false;
 
                        if (start != null) {
                                index = start.tab_index;
@@ -1554,18 +1556,14 @@ namespace System.Windows.Forms
                                index = -1;
                        }
 
-                       for (int i = 0, pos = -1; i < end; i++) {
+                       for (int i = 0; i < end; i++) {
                                if (start == container.child_controls[i]) {
-                                       pos = i;
+                                       hit = true;
                                        continue;
                                }
 
-                               if (found == null) {
-                                       if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
-                                               found = container.child_controls[i];
-                                       }
-                               } else if (found.tab_index > container.child_controls[i].tab_index) {
-                                       if (container.child_controls[i].tab_index > index) {
+                               if (found == null || found.tab_index > container.child_controls[i].tab_index) {
+                                       if (container.child_controls[i].tab_index > index || (hit && container.child_controls[i].tab_index == index)) {
                                                found = container.child_controls[i];
                                        }
                                }
@@ -1602,25 +1600,18 @@ namespace System.Windows.Forms
                        Control found;
                        int     index;
                        int     end;
+                       bool hit;
 
                        found = null;
                        end = container.child_controls.Count;
+                       hit = false;
 
                        if (start != null) {
                                index = start.tab_index;
                        } else {
-                               // FIXME: Possible speed-up: Keep the highest taborder index in the container
-                               index = -1;
-                               for (int i = 0; i < end; i++) {
-                                       if (container.child_controls[i].tab_index > index) {
-                                               index = container.child_controls[i].tab_index;
-                                       }
-                               }
-                               index++;
+                               index = int.MaxValue;
                        }
 
-                       bool hit = false;
-                                       
                        for (int i = end - 1; i >= 0; i--) {
                                if (start == container.child_controls[i]) {
                                        hit = true;