From 6a0b8886428fdeebbf0ac7d4bdac8627f4566e2b Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 26 May 2000 23:31:25 +0000 Subject: [PATCH] set the clickCoubt appropriately on MouseUp so onclicks are sent or disabled correctly b=40382 , r=joki git-svn-id: svn://10.0.0.236/trunk@70966 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsListControlFrame.cpp | 21 ++++++++++++++++++- .../html/forms/src/nsGfxListControlFrame.cpp | 19 +++++++++++++++++ .../html/forms/src/nsListControlFrame.cpp | 21 ++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 9f84dbf1503..4abacc8c901 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -60,6 +60,7 @@ #include "nsIDOMEventTarget.h" #include "nsISelectElement.h" +#include "nsIPrivateDOMEvent.h" static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID); static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID); @@ -2569,7 +2570,7 @@ nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext) view->GetDimensions(&width, &height); if (width != mRect.width || height != mRect.height) { - viewManager->ResizeView(view, mRect.width, mRect.height); + //viewManager->ResizeView(view, mRect.width, mRect.height); } nscoord x; nscoord y; @@ -2803,6 +2804,20 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) } if (IsInDropDownMode() == PR_TRUE) { + // XXX This is a bit of a hack, but..... + // But the idea here is to make sure you get an "onclick" event when you mouse + // down on the select and the drag over an option and let go + // And then NOT get an "onclick" event when when you click down on the select + // and then up outside of the select + // the EventStateManager tracks the content of the mouse down and the mouse up + // to make sure they are the same, and the onclick is sent in the PostHandleEvent + // depeneding on whether the clickCount is non-zero. + // So we cheat here by either setting or unsetting the clcikCount in the native event + // so the right thing happens for the onclick event + nsCOMPtr privateEvent(do_QueryInterface(aMouseEvent)); + nsMouseEvent * mouseEvent; + privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent); + if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, mOldSelectedIndex, mSelectedIndex))) { REFLOW_DEBUG_MSG2(">>>>>> Found Index: %d", mSelectedIndex); if (kNothingSelected != mSelectedIndex) { @@ -2811,6 +2826,10 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) if (mComboboxFrame) { mComboboxFrame->ListWasSelected(mPresContext); } + mouseEvent->clickCount = 1; + } else { + // the click was out side of the select or its dropdown + mouseEvent->clickCount = 0; } } else { REFLOW_DEBUG_MSG(">>>>>> Didn't find"); diff --git a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp index c5e582b86f5..19cb159bd99 100644 --- a/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxListControlFrame.cpp @@ -60,6 +60,7 @@ #include "nsISelectElement.h" #include "nsIScrollableFrame.h" +#include "nsIPrivateDOMEvent.h" // included for view scrolling @@ -3007,6 +3008,20 @@ nsGfxListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) } if (IsInDropDownMode() == PR_TRUE) { + // XXX This is a bit of a hack, but..... + // But the idea here is to make sure you get an "onclick" event when you mouse + // down on the select and the drag over an option and let go + // And then NOT get an "onclick" event when when you click down on the select + // and then up outside of the select + // the EventStateManager tracks the content of the mouse down and the mouse up + // to make sure they are the same, and the onclick is sent in the PostHandleEvent + // depeneding on whether the clickCount is non-zero. + // So we cheat here by either setting or unsetting the clcikCount in the native event + // so the right thing happens for the onclick event + nsCOMPtr privateEvent(do_QueryInterface(aMouseEvent)); + nsMouseEvent * mouseEvent; + privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent); + if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, mOldSelectedIndex, mSelectedIndex))) { if (kNothingSelected != mSelectedIndex) { SetContentSelected(mSelectedIndex, PR_TRUE); @@ -3014,6 +3029,10 @@ nsGfxListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) if (mComboboxFrame) { mComboboxFrame->ListWasSelected(mPresContext); } + mouseEvent->clickCount = 1; + } else { + // the click was out side of the select or its dropdown + mouseEvent->clickCount = 0; } } else if (mButtonDown) { mButtonDown = PR_FALSE; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 9f84dbf1503..4abacc8c901 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -60,6 +60,7 @@ #include "nsIDOMEventTarget.h" #include "nsISelectElement.h" +#include "nsIPrivateDOMEvent.h" static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID); static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID); @@ -2569,7 +2570,7 @@ nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext) view->GetDimensions(&width, &height); if (width != mRect.width || height != mRect.height) { - viewManager->ResizeView(view, mRect.width, mRect.height); + //viewManager->ResizeView(view, mRect.width, mRect.height); } nscoord x; nscoord y; @@ -2803,6 +2804,20 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) } if (IsInDropDownMode() == PR_TRUE) { + // XXX This is a bit of a hack, but..... + // But the idea here is to make sure you get an "onclick" event when you mouse + // down on the select and the drag over an option and let go + // And then NOT get an "onclick" event when when you click down on the select + // and then up outside of the select + // the EventStateManager tracks the content of the mouse down and the mouse up + // to make sure they are the same, and the onclick is sent in the PostHandleEvent + // depeneding on whether the clickCount is non-zero. + // So we cheat here by either setting or unsetting the clcikCount in the native event + // so the right thing happens for the onclick event + nsCOMPtr privateEvent(do_QueryInterface(aMouseEvent)); + nsMouseEvent * mouseEvent; + privateEvent->GetInternalNSEvent((nsEvent**)&mouseEvent); + if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, mOldSelectedIndex, mSelectedIndex))) { REFLOW_DEBUG_MSG2(">>>>>> Found Index: %d", mSelectedIndex); if (kNothingSelected != mSelectedIndex) { @@ -2811,6 +2826,10 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) if (mComboboxFrame) { mComboboxFrame->ListWasSelected(mPresContext); } + mouseEvent->clickCount = 1; + } else { + // the click was out side of the select or its dropdown + mouseEvent->clickCount = 0; } } else { REFLOW_DEBUG_MSG(">>>>>> Didn't find");