From 934c7a8822413160d31761461775468d6eb68261 Mon Sep 17 00:00:00 2001 From: "dean_tessman%hotmail.com" Date: Fri, 15 Feb 2002 03:53:26 +0000 Subject: [PATCH] Bug 53029 - Menu highlight by ALT key should be cleared by next key event Windows-specific changes to match behavior when a key is pressed that is not a valid access key. r=pink, sr=hyatt --- layout/xul/base/src/nsMenuBarFrame.cpp | 15 +++++++++++++++ layout/xul/base/src/nsMenuFrame.cpp | 9 ++++++++- layout/xul/base/src/nsMenuPopupFrame.cpp | 12 ++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/layout/xul/base/src/nsMenuBarFrame.cpp b/layout/xul/base/src/nsMenuBarFrame.cpp index accd412a0a7..d72f1175957 100644 --- a/layout/xul/base/src/nsMenuBarFrame.cpp +++ b/layout/xul/base/src/nsMenuBarFrame.cpp @@ -58,6 +58,10 @@ #include "nsMenuPopupFrame.h" #include "nsGUIEvent.h" #include "nsUnicharUtils.h" +#ifdef XP_WIN +#include "nsISound.h" +#include "nsWidgetsCID.h" +#endif // @@ -278,6 +282,17 @@ nsMenuBarFrame::FindMenuWithShortcut(PRUint32 aLetter) } currFrame->GetNextSibling(&currFrame); } + + // didn't find a matching menu item +#ifdef XP_WIN + // behavior on Windows - this item is on the menu bar, beep and deactivate the menu bar + nsCOMPtr soundInterface = do_CreateInstance("@mozilla.org/sound;1"); + if (soundInterface) + soundInterface->Beep(); + + DismissChain(); +#endif // #ifdef XP_WIN + return nsnull; } diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index e052a1febe5..2354b1cd369 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -1217,8 +1217,15 @@ nsMenuFrame::Escape(PRBool& aHandledFlag) NS_IMETHODIMP nsMenuFrame::Enter() { - if ( IsDisabled() ) + if (IsDisabled()) { +#ifdef XP_WIN + // behavior on Windows - close the popup chain + if (mMenuParent) + mMenuParent->DismissChain(); +#endif // #ifdef XP_WIN + // this menu item was disabled - exit return NS_OK; + } if (!mMenuOpen) { // The enter key press applies to us. diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index f3f6e5eb679..57060ee7fdc 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -69,6 +69,9 @@ #include "nsIFrameManager.h" #include "nsGUIEvent.h" #include "nsIRootBox.h" +#ifdef XP_WIN +#include "nsISound.h" +#endif static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -1500,6 +1503,15 @@ nsMenuPopupFrame::FindMenuWithShortcut(PRUint32 aLetter) } currFrame->GetNextSibling(&currFrame); } + + // didn't find a matching menu item +#ifdef XP_WIN + // behavior on Windows - this item is in a popup, beep and do nothing else + nsCOMPtr soundInterface = do_CreateInstance("@mozilla.org/sound;1"); + if (soundInterface) + soundInterface->Beep(); +#endif // #ifdef XP_WIN + return nsnull; }