Author: calberto Date: 2007-12-20 19:43:18 -0500 (Thu, 20 Dec 2007) New Revision: 91749
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
Log:
2007-12-20 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListBox.cs: When we got focus, give focus to first item if there
wasn't any pervious focused item. Also update navigation to depend on
SelectedIndex rather than FocusedItem, just as .Net does.
Fixes #349174.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-12-21 00:41:06 UTC (rev 91748)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-12-21 00:43:18 UTC (rev 91749)
@@ -1,3 +1,10 @@
+2007-12-20 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * ListBox.cs: When we got focus, give focus to first item if there
+ wasn't any pervious focused item. Also update navigation to depend on
+ SelectedIndex rather than FocusedItem, just as .Net does.
+ Fixes #349174.
+
2007-12-19 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListBox.cs: Both FindString and FindStringExact methods must do an
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
2007-12-21 00:41:06 UTC (rev 91748)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListBox.cs
2007-12-21 00:43:18 UTC (rev 91749)
@@ -1443,30 +1443,30 @@
switch (navigation) {
case ItemNavigation.PreviousColumn: {
- if (FocusedItem - RowCount < 0) {
+ if (SelectedIndex - RowCount < 0) {
return -1;
}
- if (FocusedItem - RowCount < top_index) {
- top_index = FocusedItem - RowCount;
+ if (SelectedIndex - RowCount < top_index) {
+ top_index = SelectedIndex - RowCount;
UpdateTopItem ();
}
- selected_index = FocusedItem - RowCount;
+ selected_index = SelectedIndex - RowCount;
break;
}
case ItemNavigation.NextColumn: {
- if (FocusedItem + RowCount >= Items.Count) {
+ if (SelectedIndex + RowCount >= Items.Count) {
break;
}
- if (FocusedItem + RowCount >
last_visible_index) {
- top_index = FocusedItem;
+ if (SelectedIndex + RowCount >
last_visible_index) {
+ top_index = SelectedIndex;
UpdateTopItem ();
}
- selected_index = FocusedItem + RowCount;
+ selected_index = SelectedIndex + RowCount;
break;
}
@@ -1493,19 +1493,19 @@
}
case ItemNavigation.Next: {
- if (FocusedItem == Items.Count - 1)
+ if (SelectedIndex == Items.Count - 1)
return -1;
int bottom = 0;
ArrayList heights = new ArrayList ();
if (draw_mode == DrawMode.OwnerDrawVariable) {
- for (int i = top_index; i <=
FocusedItem + 1; i++) {
+ for (int i = top_index; i <=
SelectedIndex + 1; i++) {
int h = GetItemHeight (i);
bottom += h;
heights.Add (h);
}
} else {
- bottom = ((FocusedItem + 1) - top_index
+ 1) * ItemHeight;
+ bottom = ((SelectedIndex + 1) -
top_index + 1) * ItemHeight;
}
if (bottom >= items_area.Height) {
@@ -1520,17 +1520,17 @@
top_index += offset;
UpdateTopItem ();
}
- selected_index = FocusedItem + 1;
+ selected_index = SelectedIndex + 1;
break;
}
case ItemNavigation.Previous: {
- if (FocusedItem > 0) {
- if (FocusedItem - 1 < top_index) {
+ if (SelectedIndex > 0) {
+ if (SelectedIndex - 1 < top_index) {
top_index--;
UpdateTopItem ();
}
- selected_index = FocusedItem - 1;
+ selected_index = SelectedIndex - 1;
}
break;
}
@@ -1541,18 +1541,18 @@
break;
}
- if (FocusedItem + page_size - 1 >= Items.Count)
{
+ if (SelectedIndex + page_size - 1 >=
Items.Count) {
top_index = Items.Count - page_size;
UpdateTopItem ();
selected_index = Items.Count - 1;
}
else {
- if (FocusedItem + page_size - 1 >
last_visible_index) {
- top_index = FocusedItem;
+ if (SelectedIndex + page_size - 1 >
last_visible_index) {
+ top_index = SelectedIndex;
UpdateTopItem ();
}
- selected_index = FocusedItem +
page_size - 1;
+ selected_index = SelectedIndex +
page_size - 1;
}
break;
@@ -1561,19 +1561,19 @@
case ItemNavigation.PreviousPage: {
int rows = items_area.Height / ItemHeight;
- if (FocusedItem - (rows - 1) <= 0) {
+ if (SelectedIndex - (rows - 1) <= 0) {
top_index = 0;
UpdateTopItem ();
SelectedIndex = 0;
}
else {
- if (FocusedItem - (rows - 1) <
top_index) {
- top_index = FocusedItem - (rows
- 1);
+ if (SelectedIndex - (rows - 1) <
top_index) {
+ top_index = SelectedIndex -
(rows - 1);
UpdateTopItem ();
}
- selected_index = FocusedItem - (rows -
1);
+ selected_index = SelectedIndex - (rows
- 1);
}
break;
@@ -1588,8 +1588,13 @@
private void OnGotFocus (object sender, EventArgs e)
{
- if (FocusedItem != -1)
- InvalidateItem (FocusedItem);
+ if (Items.Count == 0)
+ return;
+
+ if (FocusedItem == -1)
+ FocusedItem = 0;
+
+ InvalidateItem (FocusedItem);
}
private void OnLostFocus (object sender, EventArgs e)
@@ -1604,7 +1609,7 @@
if (!Char.IsLetterOrDigit (c))
return false;
- int idx = FindString (c.ToString (), FocusedItem);
+ int idx = FindString (c.ToString (), SelectedIndex);
if (idx != ListBox.NoMatches)
SelectedIndex = idx;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
