49401: yet another attempt to get menu access keys right.

Change the KeyPress handler to check event flags if we aren't in
  access key focuses mode (it probably should anyway).  r=saari
This commit is contained in:
akkana%netscape.com 2000-08-30 00:33:58 +00:00
Родитель b8323064d4
Коммит c44543ffab
2 изменённых файлов: 35 добавлений и 16 удалений

Просмотреть файл

@ -167,7 +167,17 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);
if (mAccessKeyDown && ((PRInt32)theChar != mAccessKey)) {
PRBool doShortcut = PR_FALSE;
if (!mAccessKeyFocuses) {
if (IsAccessKeyPressed(keyEvent) && (theChar != (PRUint32)mAccessKey))
doShortcut = PR_TRUE;
}
else if (mAccessKeyDown && (theChar != (PRUint32)mAccessKey)) {
doShortcut = PR_TRUE;
}
if (doShortcut)
{
mAccessKeyDown = PR_FALSE;
// Do shortcut navigation.
@ -190,6 +200,26 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
PRBool
nsMenuBarListener::IsAccessKeyPressed(nsIDOMKeyEvent* aKeyEvent)
{
PRBool access;
switch (mAccessKey)
{
case nsIDOMKeyEvent::DOM_VK_CONTROL:
aKeyEvent->GetCtrlKey(&access);
return access;
case nsIDOMKeyEvent::DOM_VK_ALT:
aKeyEvent->GetAltKey(&access);
return access;
case nsIDOMKeyEvent::DOM_VK_META:
aKeyEvent->GetMetaKey(&access);
return access;
default:
return PR_FALSE;
}
}
////////////////////////////////////////////////////////////////////////
nsresult
nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
@ -202,21 +232,7 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
PRUint32 theChar;
keyEvent->GetKeyCode(&theChar);
PRBool access;
switch (mAccessKey)
{
case nsIDOMKeyEvent::DOM_VK_CONTROL:
keyEvent->GetCtrlKey(&access);
break;
case nsIDOMKeyEvent::DOM_VK_ALT:
keyEvent->GetAltKey(&access);
break;
case nsIDOMKeyEvent::DOM_VK_META:
keyEvent->GetMetaKey(&access);
break;
default:
access = 0;
}
PRBool access = IsAccessKeyPressed(keyEvent);
if (theChar == nsIDOMKeyEvent::DOM_VK_TAB && mAccessKeyDown) {
mAccessKeyDown = PR_FALSE;
}

Просмотреть файл

@ -32,6 +32,7 @@
class nsMenuBarFrame;
class nsIPresContext;
class nsIDOMKeyEvent;
/** editor Implementation of the DragListener interface
*/
@ -68,6 +69,8 @@ public:
protected:
static void InitAccessKey();
PRBool IsAccessKeyPressed(nsIDOMKeyEvent* event);
nsMenuBarFrame* mMenuBarFrame; // The menu bar object.
PRBool mAccessKeyDown; // Whether or not the ALT key is currently down.
static PRBool mAccessKeyFocuses; // Does the access key by itself focus the menubar?