Fix to bug 14368 - Win32 - F10 key does not activate the menu bar.

r=dean_tessman@hotmail.com, sr=hyatt@netscape.com
This commit is contained in:
markh%activestate.com 2001-03-12 09:53:33 +00:00
parent eeb1d1acb8
commit 1f60ff29b4
2 changed files with 28 additions and 2 deletions

View File

@ -20,6 +20,8 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Contributor(s):
* Dean Tessman <dean_tessman@hotmail.com>
* Mark Hammond <markh@ActiveState.com>
*/
#include "nsMenuBarListener.h"
@ -205,6 +207,26 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
retVal = NS_ERROR_BASE; // I am consuming event
}
}
#ifdef XP_WIN
// Also need to handle F10 specially on Windows.
else if (theChar == NS_VK_F10) {
PRBool alt,ctrl,shift,meta;
keyEvent->GetAltKey(&alt);
keyEvent->GetCtrlKey(&ctrl);
keyEvent->GetShiftKey(&shift);
keyEvent->GetMetaKey(&meta);
if (!(shift || alt || meta)) {
// The F10 key just went down by itself or with ctrl pressed.
// In Windows, both of these activate the menu bar.
mMenuBarFrame->ToggleMenuActiveState();
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
aKeyEvent->PreventDefault();
return NS_ERROR_BASE; // consume the event
}
}
#endif // XP_WIN
}
}
return retVal;

View File

@ -2923,8 +2923,12 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
result = PR_FALSE;
}
if (wParam == VK_MENU) {
// This is required to make XP menus work.
if (wParam == VK_MENU || wParam == VK_F10) {
// This is required to prevent Windows
// default menu processing getting in the
// way of XP menus and key handling.
// Without this we call DefWindowProc which will
// send us WM_COMMAND and/or WM_SYSCOMMAND messages.
// Do not remove! Talk to me if you have
// questions. - hyatt@netscape.com
result = PR_TRUE;