fix for 27879, r=saari

git-svn-id: svn://10.0.0.236/trunk@61296 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hyatt%netscape.com
2000-02-18 10:05:14 +00:00
parent 5de7211510
commit 7049c9cba6
2 changed files with 38 additions and 28 deletions

View File

@@ -215,8 +215,12 @@ nsMenuBarFrame::FindMenuWithShortcut(PRUint32 aLetter)
shortcutKey.ToUpperCase();
if (shortcutKey.Length() > 0) {
// We've got something.
PRUnichar shortcutChar = shortcutKey.CharAt(0);
if (shortcutChar == aLetter) {
char tempChar[2];
tempChar[0] = aLetter;
tempChar[1] = 0;
nsAutoString tempChar2 = tempChar;
if (shortcutKey.EqualsIgnoreCase(tempChar2)) {
// We match!
nsCOMPtr<nsIMenuFrame> menuFrame = do_QueryInterface(currFrame);
if (menuFrame)

View File

@@ -98,6 +98,38 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
#ifndef XP_UNIX
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);
if (mAltKeyDown && (theChar != NS_VK_ALT)) {
mAltKeyDown = PR_FALSE;
// Do shortcut navigation.
// A letter was pressed. We want to see if a shortcut gets matched. If
// so, we'll know the menu got activated.
keyEvent->GetCharCode(&theChar);
PRBool active = PR_FALSE;
mMenuBarFrame->ShortcutNavigation(theChar, active);
if (active) {
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
aKeyEvent->PreventDefault();
}
return NS_ERROR_BASE; // I am consuming event
}
#endif
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
@@ -125,38 +157,12 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
// The ALT key just went down by itself. Track this.
mAltKeyDown = PR_TRUE;
}
return NS_OK;
}
if (mAltKeyDown) {
mAltKeyDown = PR_FALSE;
// Do shortcut navigation.
// A letter was pressed. We want to see if a shortcut gets matched. If
// so, we'll know the menu got activated.
PRBool active = PR_FALSE;
mMenuBarFrame->ShortcutNavigation(theChar, active);
if (active) {
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
aKeyEvent->PreventDefault();
}
return NS_ERROR_BASE; // I am consuming event
}
#endif
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
{
return NS_OK; // means I am NOT consuming event
}
////////////////////////////////////////////////////////////////////////
nsresult