Initial shift click will now work correctly for mulitple with selected items

it now will scroll to the selected items on start up
b 24178,7025 r=kmcclusk


git-svn-id: svn://10.0.0.236/trunk@58154 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rods%netscape.com 2000-01-18 23:33:22 +00:00
parent 322adbdae3
commit fbc2f561f0
3 changed files with 115 additions and 27 deletions

View File

@ -345,6 +345,18 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
return skiprv;
}
#endif
// XXX So this may do it too often
// the side effect of this is if the user has scrolled to some other place in the list and
// an incremental reflow comes through the list gets scrolled to the first selected item
// I haven't been able to make it do it, but it will do it
// basically the real solution is to know when all the reframes are there.
if (aReflowState.reason == eReflowReason_Incremental) {
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
}
// Strategy: Let the inherited reflow happen as though the width and height of the
// ScrollFrame are big enough to allow the listbox to
// shrink to fit the longest option element line in the list.
@ -853,10 +865,6 @@ nsListControlFrame::SingleSelection()
}
// Display the new selection
SetContentSelected(mSelectedIndex, PR_TRUE);
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
} else {
// Selecting the currently selected item so do nothing.
}
@ -1418,6 +1426,11 @@ nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected)
if (nsnull != content) {
if (aSelected) {
DisplaySelected(content);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(content));
if (content) {
ScrollToFrame(content);
}
} else {
DisplayDeselected(content);
}
@ -1523,7 +1536,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext)
PRUint32 numOptions;
options->GetLength(&numOptions);
mSelectedIndex = kNothingSelected;
mSelectedIndex = kNothingSelected;
mStartExtendedIndex = kNothingSelected;
mEndExtendedIndex = kNothingSelected;
PRBool multiple;
GetMultiple(&multiple);
Deselect();
PRUint32 i;
@ -1536,10 +1553,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext)
mSelectedIndex = i;
SetContentSelected(i, PR_TRUE);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(option));
if (content) {
ScrollToFrame(content);
if (multiple) {
mStartExtendedIndex = i;
if (mEndExtendedIndex == kNothingSelected) {
mEndExtendedIndex = i;
}
}
if (mComboboxFrame) {
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
@ -2586,6 +2604,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
nsIFrame * parentFrame;
frame->GetParent(&parentFrame);
stateManager->GetEventTarget(&frame);
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
}
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);

View File

@ -114,6 +114,11 @@ nsGfxListControlFrame::nsGfxListControlFrame()
mIsAllContentHere = PR_FALSE;
mIsAllFramesHere = PR_FALSE;
mHasBeenInitialized = PR_FALSE;
mCacheSize.width = -1;
mCacheSize.height = -1;
mCachedMaxElementSize.width = -1;
mCachedMaxElementSize.height = -1;
}
//---------------------------------------------------------
@ -330,6 +335,25 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
}
}
#if 1
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext,
aDesiredSize, aReflowState, aStatus);
if (NS_SUCCEEDED(skiprv)) {
return skiprv;
}
#endif
// XXX So this may do it too often
// the side effect of this is if the user has scrolled to some other place in the list and
// an incremental reflow comes through the list gets scrolled to the first selected item
// I haven't been able to make it do it, but it will do it
// basically the real solution is to know when all the reframes are there.
if (aReflowState.reason == eReflowReason_Incremental) {
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
}
nsIFrame * firstChildFrame = nsnull;
FirstChild(nsnull, &firstChildFrame);
@ -606,6 +630,8 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext,
}
#endif
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
return NS_OK;
}
@ -872,10 +898,6 @@ nsGfxListControlFrame::SingleSelection()
}
// Display the new selection
SetContentSelected(mSelectedIndex, PR_TRUE);
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
} else {
// Selecting the currently selected item so do nothing.
}
@ -1435,6 +1457,11 @@ nsGfxListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected)
if (nsnull != content) {
if (aSelected) {
DisplaySelected(content);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(content));
if (content) {
ScrollToFrame(content);
}
} else {
DisplayDeselected(content);
}
@ -1540,7 +1567,11 @@ nsGfxListControlFrame::Reset(nsIPresContext* aPresContext)
PRUint32 numOptions;
options->GetLength(&numOptions);
mSelectedIndex = kNothingSelected;
mSelectedIndex = kNothingSelected;
mStartExtendedIndex = kNothingSelected;
mEndExtendedIndex = kNothingSelected;
PRBool multiple;
GetMultiple(&multiple);
Deselect();
PRUint32 i;
@ -1553,10 +1584,11 @@ nsGfxListControlFrame::Reset(nsIPresContext* aPresContext)
mSelectedIndex = i;
SetContentSelected(i, PR_TRUE);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(option));
if (content) {
ScrollToFrame(content);
if (multiple) {
mStartExtendedIndex = i;
if (mEndExtendedIndex == kNothingSelected) {
mEndExtendedIndex = i;
}
}
if (mComboboxFrame) {
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event

View File

@ -345,6 +345,18 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
return skiprv;
}
#endif
// XXX So this may do it too often
// the side effect of this is if the user has scrolled to some other place in the list and
// an incremental reflow comes through the list gets scrolled to the first selected item
// I haven't been able to make it do it, but it will do it
// basically the real solution is to know when all the reframes are there.
if (aReflowState.reason == eReflowReason_Incremental) {
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
}
// Strategy: Let the inherited reflow happen as though the width and height of the
// ScrollFrame are big enough to allow the listbox to
// shrink to fit the longest option element line in the list.
@ -853,10 +865,6 @@ nsListControlFrame::SingleSelection()
}
// Display the new selection
SetContentSelected(mSelectedIndex, PR_TRUE);
nsCOMPtr<nsIContent> content = getter_AddRefs(GetOptionContent(mSelectedIndex));
if (content) {
ScrollToFrame(content);
}
} else {
// Selecting the currently selected item so do nothing.
}
@ -1418,6 +1426,11 @@ nsListControlFrame::SetContentSelected(PRInt32 aIndex, PRBool aSelected)
if (nsnull != content) {
if (aSelected) {
DisplaySelected(content);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(content));
if (content) {
ScrollToFrame(content);
}
} else {
DisplayDeselected(content);
}
@ -1523,7 +1536,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext)
PRUint32 numOptions;
options->GetLength(&numOptions);
mSelectedIndex = kNothingSelected;
mSelectedIndex = kNothingSelected;
mStartExtendedIndex = kNothingSelected;
mEndExtendedIndex = kNothingSelected;
PRBool multiple;
GetMultiple(&multiple);
Deselect();
PRUint32 i;
@ -1536,10 +1553,11 @@ nsListControlFrame::Reset(nsIPresContext* aPresContext)
mSelectedIndex = i;
SetContentSelected(i, PR_TRUE);
// Now that it is selected scroll to it
nsCOMPtr<nsIContent> content(do_QueryInterface(option));
if (content) {
ScrollToFrame(content);
if (multiple) {
mStartExtendedIndex = i;
if (mEndExtendedIndex == kNothingSelected) {
mEndExtendedIndex = i;
}
}
if (mComboboxFrame) {
mComboboxFrame->UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // don't dispatch event
@ -2586,6 +2604,16 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
} else {
nsIFrame * parentFrame;
frame->GetParent(&parentFrame);
stateManager->GetEventTarget(&frame);
nsCOMPtr<nsIListControlFrame> listFrame(do_QueryInterface(frame));
if (listFrame) {
if (!IsClickingInCombobox(aMouseEvent)) {
return NS_OK;
}
}
}
// This will consume the focus event we get from the clicking on the dropdown
//stateManager->ConsumeFocusEvents(PR_TRUE);