From 013af7626ef74c3ce5945fac48c501d1451cf60d Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Mon, 19 Jul 1999 09:36:24 +0000 Subject: [PATCH] Making sure the left and right arrow navigation only fires when the menu bar is active. --- layout/xul/base/src/nsMenuBarListener.cpp | 5 +++-- layout/xul/base/src/nsMenuFrame.cpp | 9 +++++++++ layout/xul/base/src/nsMenuFrame.h | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/layout/xul/base/src/nsMenuBarListener.cpp b/layout/xul/base/src/nsMenuBarListener.cpp index f47ee71167e..c458aa32877 100644 --- a/layout/xul/base/src/nsMenuBarListener.cpp +++ b/layout/xul/base/src/nsMenuBarListener.cpp @@ -149,7 +149,7 @@ nsMenuBarListener::MouseMove(nsIDOMEvent* aMouseEvent) if (tag && (tag.get() == nsXULAtoms::xpmenu)) { // We found a menu. mMenuBarFrame->SetCurrentMenuItem(current); - break; + return NS_OK; } // Get our parent. @@ -253,7 +253,8 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) theChar == NS_VK_DOWN) { // The arrow keys were pressed. User is moving around within // the menus. - mMenuBarFrame->KeyboardNavigation(theChar); + if (mMenuBarFrame->IsActive()) + mMenuBarFrame->KeyboardNavigation(theChar); } if (mMenuBarFrame->IsActive()) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 7b15ed0ce41..ead30bb7956 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -112,3 +112,12 @@ nsMenuFrame::DeleteFrame(nsIPresContext& aPresContext) mPopupFrames.DeleteFrames(aPresContext); return nsAreaFrame::DeleteFrame(aPresContext); } + +// Called to prevent events from going to anything inside the menu. +NS_IMETHODIMP +nsMenuFrame::GetFrameForPoint(const nsPoint& aPoint, + nsIFrame** aFrame) +{ + *aFrame = this; // Capture all events so that we can perform selection + return NS_OK; +} \ No newline at end of file diff --git a/layout/xul/base/src/nsMenuFrame.h b/layout/xul/base/src/nsMenuFrame.h index 3fbc3d122b6..172143383ba 100644 --- a/layout/xul/base/src/nsMenuFrame.h +++ b/layout/xul/base/src/nsMenuFrame.h @@ -50,6 +50,10 @@ public: nsIAtom** aListName) const; NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); + // Overridden to prevent events from ever going to children of the menu. + NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, + nsIFrame** aFrame); + protected: nsFrameList mPopupFrames; }; // class nsMenuFrame