The selectedindex is now getting set to -1 when there are no more items selected and it

is sending onchange events by clearing the mOldSelectedIndex.
Bug 68135 r=kmcclusk sr=attinasi a=dbaron
This commit is contained in:
rods%netscape.com 2001-06-06 10:41:17 +00:00
parent f33f79f4e4
commit 9e16855ea0
2 changed files with 44 additions and 2 deletions

View File

@ -1303,9 +1303,30 @@ nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
}
}
} else if (aIsControl) {
// Control is held down
// Control is held down
if (IsContentSelectedByIndex(mSelectedIndex)) {
SetContentSelected(mSelectedIndex, PR_FALSE);
// after clearing the selected item
// we need to check to see if there are any more
// selected items
PRInt32 i;
PRInt32 max = 0;
if (NS_SUCCEEDED(GetNumberOfOptions(&max))) {
for (i=0;i<max;i++) {
if (IsContentSelectedByIndex(i)) {
// set this to "-1" to force the dispatch of the onchange event
mOldSelectedIndex = -1;
break;
}
}
}
// didn't find any other seleccted items
// so we must set the currently selected item to "-1"
// this also forces the dispatch of the onchange event
if (i == max) {
mSelectedIndex = -1;
}
} else {
SetContentSelected(mSelectedIndex, PR_TRUE);
}

View File

@ -1303,9 +1303,30 @@ nsListControlFrame::MultipleSelection(PRBool aIsShift, PRBool aIsControl)
}
}
} else if (aIsControl) {
// Control is held down
// Control is held down
if (IsContentSelectedByIndex(mSelectedIndex)) {
SetContentSelected(mSelectedIndex, PR_FALSE);
// after clearing the selected item
// we need to check to see if there are any more
// selected items
PRInt32 i;
PRInt32 max = 0;
if (NS_SUCCEEDED(GetNumberOfOptions(&max))) {
for (i=0;i<max;i++) {
if (IsContentSelectedByIndex(i)) {
// set this to "-1" to force the dispatch of the onchange event
mOldSelectedIndex = -1;
break;
}
}
}
// didn't find any other seleccted items
// so we must set the currently selected item to "-1"
// this also forces the dispatch of the onchange event
if (i == max) {
mSelectedIndex = -1;
}
} else {
SetContentSelected(mSelectedIndex, PR_TRUE);
}