From 8dcfbf153d70376268dfe089c89190ddd63e969b Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Mon, 26 Jul 1999 04:38:28 +0000 Subject: [PATCH] Fixing more keyboard navigation glitches in XP menus. --- layout/xul/base/src/nsMenuFrame.cpp | 25 ++++++++++++++++-------- layout/xul/base/src/nsMenuPopupFrame.cpp | 13 ++++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 7ccd3c2243a..9d18ae60ac9 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -243,8 +243,12 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext, if (isActive) cancel = PR_FALSE; } - if (cancel) - mMenuParent->SetCurrentMenuItem(nsnull); + if (cancel) { + if (IsMenu() && !isMenuBar && mMenuOpen) { + // Submenus don't get closed up. + } + else mMenuParent->SetCurrentMenuItem(nsnull); + } } } else if (aEvent->message == NS_MOUSE_MOVE && mMenuParent) { @@ -480,14 +484,19 @@ void nsMenuFrame::Notify(nsITimer* aTimer) { // Our timer has fired. - if (!mMenuOpen && mMenuParent) { - nsAutoString active = ""; - mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, active); - if (active == "true") { - // We're still the active menu. - OpenMenu(PR_TRUE); + if (aTimer == mOpenTimer.get()) { + if (!mMenuOpen && mMenuParent) { + nsAutoString active = ""; + mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, active); + if (active == "true") { + // We're still the active menu. + OpenMenu(PR_TRUE); + } } + mOpenTimer->Cancel(); + mOpenTimer = nsnull; } + mOpenTimer = nsnull; } diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 327aaf8d4bd..72d00b88a87 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -486,11 +486,16 @@ nsMenuPopupFrame::KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag) aHandledFlag = PR_TRUE; } - else if (aDirection == NS_VK_LEFT && mCurrentMenu && - menuFrame->IsMenu()) { - // Close it up. + else if (mCurrentMenu && menuFrame->IsMenu() && menuFrame->IsOpen()) { aHandledFlag = PR_TRUE; - menuFrame->OpenMenu(PR_FALSE); + if (aDirection == NS_VK_LEFT) { + // Close it up. + menuFrame->OpenMenu(PR_FALSE); + } + else if (aDirection == NS_VK_RIGHT) { + // Select the first item. + menuFrame->SelectFirstItem(); + } } }