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,9 +510,8 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} else { } else {
mFocused = nsnull; mFocused = nsnull;
if (mDroppedDown) { if (mDroppedDown) {
ToggleList(mPresContext); mListControlFrame->ComboboxFinish(mDisplayedIndex);
} } else {
// Fire onChange if selected index has changed due to keyboard // Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection) // (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) { if (mNeedToFireOnChange) {
@@ -527,6 +526,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} }
} }
} }
}
// This is needed on a temporary basis. It causes the focus // This is needed on a temporary basis. It causes the focus
// rect to be drawn. This is much faster than ReResolvingStyle // rect to be drawn. This is much faster than ReResolvingStyle

View File

@@ -125,6 +125,13 @@ public:
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext,
nsIFrame** aFrame) = 0; 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 #endif

View File

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

View File

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

View File

@@ -125,6 +125,13 @@ public:
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext,
nsIFrame** aFrame) = 0; 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 #endif

View File

@@ -510,9 +510,8 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} else { } else {
mFocused = nsnull; mFocused = nsnull;
if (mDroppedDown) { if (mDroppedDown) {
ToggleList(mPresContext); mListControlFrame->ComboboxFinish(mDisplayedIndex);
} } else {
// Fire onChange if selected index has changed due to keyboard // Fire onChange if selected index has changed due to keyboard
// (see nsListControlFrame::UpdateSelection) // (see nsListControlFrame::UpdateSelection)
if (mNeedToFireOnChange) { if (mNeedToFireOnChange) {
@@ -527,6 +526,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
} }
} }
} }
}
// This is needed on a temporary basis. It causes the focus // This is needed on a temporary basis. It causes the focus
// rect to be drawn. This is much faster than ReResolvingStyle // rect to be drawn. This is much faster than ReResolvingStyle

View File

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

View File

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