Tabbing out of dropdown does not reset selected item (bug 100188), r=rods@netscape.com, sr=attinasi@netscape.com

This commit is contained in:
jkeiser@netscape.com
2002-02-20 05:59:46 +00:00
parent 5f1e222876
commit a2b587a53f
8 changed files with 50 additions and 34 deletions

View File

@@ -510,20 +510,20 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} else {
mFocused = nsnull;
if (mDroppedDown) {
ToggleList(mPresContext);
}
// Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) {
PRInt32 selectedIndex;
mListControlFrame->GetSelectedIndex(&selectedIndex);
if (selectedIndex != mRecentSelectedIndex) {
// mNeedToFireOnChange will be set to false from within FireOnChange
mListControlFrame->FireOnChange();
} else {
// Need to set it to false anyway ... just in case
SetNeedToFireOnChange(PR_FALSE);
mListControlFrame->ComboboxFinish(mDisplayedIndex);
} else {
// Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) {
PRInt32 selectedIndex;
mListControlFrame->GetSelectedIndex(&selectedIndex);
if (selectedIndex != mRecentSelectedIndex) {
// mNeedToFireOnChange will be set to false from within FireOnChange
mListControlFrame->FireOnChange();
} else {
// Need to set it to false anyway ... just in case
SetNeedToFireOnChange(PR_FALSE);
}
}
}
}

View File

@@ -125,6 +125,13 @@ public:
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext,
nsIFrame** aFrame) = 0;
/**
* Tell the selected list to roll up and ensure that the proper index is
* selected, possibly firing onChange if the index has changed
*
* @param aIndex the index to actually select
*/
NS_IMETHOD ComboboxFinish(PRInt32 aIndex) = 0;
};
#endif

View File

@@ -2110,7 +2110,7 @@ nsListControlFrame::UpdateSelection()
return rv;
}
void
NS_IMETHODIMP
nsListControlFrame::ComboboxFinish(PRInt32 aIndex)
{
if (mComboboxFrame) {
@@ -2129,6 +2129,8 @@ nsListControlFrame::ComboboxFinish(PRInt32 aIndex)
FireOnChange();
}
}
return NS_OK;
}
NS_IMETHODIMP

View File

@@ -277,7 +277,7 @@ public:
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) { mOverrideReflowOpt = aValue; return NS_OK; }
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** aFrame);
NS_IMETHOD FireOnChange();
NS_IMETHOD ComboboxFinish(PRInt32 aIndex);
// nsISelectControlFrame
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
@@ -362,7 +362,6 @@ protected:
// Dropped down stuff
void SetComboboxItem(PRInt32 aIndex);
void ComboboxFinish(PRInt32 aIndex);
PRBool IsInDropDownMode();
// Selection

View File

@@ -125,6 +125,13 @@ public:
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext,
nsIFrame** aFrame) = 0;
/**
* Tell the selected list to roll up and ensure that the proper index is
* selected, possibly firing onChange if the index has changed
*
* @param aIndex the index to actually select
*/
NS_IMETHOD ComboboxFinish(PRInt32 aIndex) = 0;
};
#endif

View File

@@ -510,20 +510,20 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} else {
mFocused = nsnull;
if (mDroppedDown) {
ToggleList(mPresContext);
}
// Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) {
PRInt32 selectedIndex;
mListControlFrame->GetSelectedIndex(&selectedIndex);
if (selectedIndex != mRecentSelectedIndex) {
// mNeedToFireOnChange will be set to false from within FireOnChange
mListControlFrame->FireOnChange();
} else {
// Need to set it to false anyway ... just in case
SetNeedToFireOnChange(PR_FALSE);
mListControlFrame->ComboboxFinish(mDisplayedIndex);
} else {
// Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) {
PRInt32 selectedIndex;
mListControlFrame->GetSelectedIndex(&selectedIndex);
if (selectedIndex != mRecentSelectedIndex) {
// mNeedToFireOnChange will be set to false from within FireOnChange
mListControlFrame->FireOnChange();
} else {
// Need to set it to false anyway ... just in case
SetNeedToFireOnChange(PR_FALSE);
}
}
}
}

View File

@@ -2110,7 +2110,7 @@ nsListControlFrame::UpdateSelection()
return rv;
}
void
NS_IMETHODIMP
nsListControlFrame::ComboboxFinish(PRInt32 aIndex)
{
if (mComboboxFrame) {
@@ -2129,6 +2129,8 @@ nsListControlFrame::ComboboxFinish(PRInt32 aIndex)
FireOnChange();
}
}
return NS_OK;
}
NS_IMETHODIMP

View File

@@ -277,7 +277,7 @@ public:
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) { mOverrideReflowOpt = aValue; return NS_OK; }
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** aFrame);
NS_IMETHOD FireOnChange();
NS_IMETHOD ComboboxFinish(PRInt32 aIndex);
// nsISelectControlFrame
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
@@ -362,7 +362,6 @@ protected:
// Dropped down stuff
void SetComboboxItem(PRInt32 aIndex);
void ComboboxFinish(PRInt32 aIndex);
PRBool IsInDropDownMode();
// Selection