Bug 757330 Don't activate an empty menubar r=Enn

This commit is contained in:
Neil Rashbrook 2012-05-30 08:33:20 +01:00
parent 9bf1a59717
commit a395dd73d3
2 changed files with 8 additions and 6 deletions

View File

@ -149,15 +149,15 @@ nsMenuBarFrame::ToggleMenuActiveState()
// if the menu bar is already selected (eg. mouseover), deselect it
if (mCurrentMenu)
mCurrentMenu->SelectMenu(false);
// Activate the menu bar
SetActive(true);
// Set the active menu to be the top left item (e.g., the File menu).
// We use an attribute called "menuactive" to track the current
// active menu.
nsMenuFrame* firstFrame = nsXULPopupManager::GetNextMenuItem(this, nsnull, false);
if (firstFrame) {
// Activate the menu bar
SetActive(true);
#ifdef MOZ_WIDGET_GTK2
firstFrame->OpenMenu(true);
#else

View File

@ -240,9 +240,11 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
mMenuBarFrame->SetActiveByKeyboard();
ToggleMenuActiveState();
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
return NS_OK; // consume the event
if (mMenuBarFrame->IsActive()) {
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
return NS_OK; // consume the event
}
}
}
#endif // !XP_MACOSX