Fix regression from bug 244761 so that only user actions will enable onChange after blur b=251833 r/sr=roc

This commit is contained in:
neil%parkwaycc.co.uk 2004-07-23 08:25:44 +00:00
Родитель 1e3d3e88de
Коммит 92f587883a
8 изменённых файлов: 50 добавлений и 40 удалений

Просмотреть файл

@ -484,13 +484,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
if (aOn) {
nsListControlFrame::ComboboxFocusSet();
if (mFocused != this) {
mFocused = this;
// Store up the selected index so when we lose focus we can see if it's
// really changed
mListControlFrame->GetSelectedIndex(&mRecentSelectedIndex);
}
mFocused = this;
} else {
mFocused = nsnull;
if (mDroppedDown) {
@ -2254,16 +2248,13 @@ nsComboboxControlFrame::RollupFromList(nsIPresContext* aPresContext)
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
nsComboboxControlFrame::NeededToFireOnChange()
NS_IMETHODIMP_(PRInt32)
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
{
PRInt32 index;
mListControlFrame->GetSelectedIndex(&index);
if (index == mRecentSelectedIndex)
return PR_FALSE;
mRecentSelectedIndex = index;
return PR_TRUE;
PRInt32 index = mRecentSelectedIndex;
if (mRecentSelectedIndex == -1 || aIndex == -1)
mRecentSelectedIndex = aIndex;
return index;
}
NS_METHOD

Просмотреть файл

@ -174,7 +174,7 @@ public:
NS_IMETHOD GetAbsoluteRect(nsRect* aRect);
NS_IMETHOD GetIndexOfDisplayArea(PRInt32* aSelectedIndex);
NS_IMETHOD RedisplaySelectedText();
NS_IMETHOD_(PRBool) NeededToFireOnChange();
NS_IMETHOD_(PRInt32) UpdateRecentIndex(PRInt32 aIndex);
// nsISelectControlFrame
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);

Просмотреть файл

@ -94,9 +94,9 @@ public:
NS_IMETHOD RedisplaySelectedText() = 0;
/**
* Method for the listbox to ask the combobox if onChange should be fired
* Method for the listbox to set and get the recent index
*/
NS_IMETHOD_(PRBool) NeededToFireOnChange() = 0;
NS_IMETHOD_(PRInt32) UpdateRecentIndex(PRInt32 aIndex) = 0;
/**
*

Просмотреть файл

@ -1488,6 +1488,12 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex,
PRBool
nsListControlFrame::SingleSelection(PRInt32 aClickedIndex, PRBool aDoToggle)
{
if (mComboboxFrame) {
PRInt32 selectedIndex;
GetSelectedIndex(&selectedIndex);
mComboboxFrame->UpdateRecentIndex(selectedIndex);
}
PRBool wasChanged = PR_FALSE;
// Get Current selection
if (aDoToggle) {
@ -2425,7 +2431,15 @@ nsListControlFrame::FireOnChange()
nsresult rv = NS_OK;
if (mComboboxFrame) {
if (!mComboboxFrame->NeededToFireOnChange())
// Return hit without changing anything
PRInt32 index = mComboboxFrame->UpdateRecentIndex(-1);
if (index == -1)
return NS_OK;
// See if the selection actually changed
PRInt32 selectedIndex;
GetSelectedIndex(&selectedIndex);
if (index == selectedIndex)
return NS_OK;
}

Просмотреть файл

@ -94,9 +94,9 @@ public:
NS_IMETHOD RedisplaySelectedText() = 0;
/**
* Method for the listbox to ask the combobox if onChange should be fired
* Method for the listbox to set and get the recent index
*/
NS_IMETHOD_(PRBool) NeededToFireOnChange() = 0;
NS_IMETHOD_(PRInt32) UpdateRecentIndex(PRInt32 aIndex) = 0;
/**
*

Просмотреть файл

@ -484,13 +484,7 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
if (aOn) {
nsListControlFrame::ComboboxFocusSet();
if (mFocused != this) {
mFocused = this;
// Store up the selected index so when we lose focus we can see if it's
// really changed
mListControlFrame->GetSelectedIndex(&mRecentSelectedIndex);
}
mFocused = this;
} else {
mFocused = nsnull;
if (mDroppedDown) {
@ -2254,16 +2248,13 @@ nsComboboxControlFrame::RollupFromList(nsIPresContext* aPresContext)
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
nsComboboxControlFrame::NeededToFireOnChange()
NS_IMETHODIMP_(PRInt32)
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
{
PRInt32 index;
mListControlFrame->GetSelectedIndex(&index);
if (index == mRecentSelectedIndex)
return PR_FALSE;
mRecentSelectedIndex = index;
return PR_TRUE;
PRInt32 index = mRecentSelectedIndex;
if (mRecentSelectedIndex == -1 || aIndex == -1)
mRecentSelectedIndex = aIndex;
return index;
}
NS_METHOD

Просмотреть файл

@ -174,7 +174,7 @@ public:
NS_IMETHOD GetAbsoluteRect(nsRect* aRect);
NS_IMETHOD GetIndexOfDisplayArea(PRInt32* aSelectedIndex);
NS_IMETHOD RedisplaySelectedText();
NS_IMETHOD_(PRBool) NeededToFireOnChange();
NS_IMETHOD_(PRInt32) UpdateRecentIndex(PRInt32 aIndex);
// nsISelectControlFrame
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);

Просмотреть файл

@ -1488,6 +1488,12 @@ nsListControlFrame::ExtendedSelection(PRInt32 aStartIndex,
PRBool
nsListControlFrame::SingleSelection(PRInt32 aClickedIndex, PRBool aDoToggle)
{
if (mComboboxFrame) {
PRInt32 selectedIndex;
GetSelectedIndex(&selectedIndex);
mComboboxFrame->UpdateRecentIndex(selectedIndex);
}
PRBool wasChanged = PR_FALSE;
// Get Current selection
if (aDoToggle) {
@ -2425,7 +2431,15 @@ nsListControlFrame::FireOnChange()
nsresult rv = NS_OK;
if (mComboboxFrame) {
if (!mComboboxFrame->NeededToFireOnChange())
// Return hit without changing anything
PRInt32 index = mComboboxFrame->UpdateRecentIndex(-1);
if (index == -1)
return NS_OK;
// See if the selection actually changed
PRInt32 selectedIndex;
GetSelectedIndex(&selectedIndex);
if (index == selectedIndex)
return NS_OK;
}