зеркало из https://github.com/mozilla/pjs.git
Handling Enter key press in submenus.
This commit is contained in:
Родитель
61da273cf3
Коммит
0e2798a61d
|
@ -418,7 +418,7 @@ nsMenuBarFrame::Enter()
|
|||
nsMenuFrame* menuFrame = (nsMenuFrame*)mCurrentMenu;
|
||||
if (menuFrame->IsOpen()) {
|
||||
// Let the child menu handle this.
|
||||
// menuFrame->Enter();
|
||||
menuFrame->Enter();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,8 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
|||
if (active)
|
||||
mMenuBarFrame->Escape();
|
||||
}
|
||||
else if (theChar == NS_VK_ENTER) {
|
||||
else if (theChar == NS_VK_ENTER ||
|
||||
theChar == NS_VK_RETURN) {
|
||||
// Open one level.
|
||||
if (active)
|
||||
mMenuBarFrame->Enter();
|
||||
|
|
|
@ -203,6 +203,7 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
}
|
||||
else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
||||
// The menu item was invoked and can now be dismissed.
|
||||
// XXX Execute the execute event handler.
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mContent->GetTag(*getter_AddRefs(tag));
|
||||
if (tag.get() == nsXULAtoms::xpmenuitem && mMenuParent) {
|
||||
|
@ -268,7 +269,7 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
|||
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
||||
|
||||
if (aActivateFlag) {
|
||||
|
||||
// XXX Execute the oncreate handler
|
||||
// Sync up the view.
|
||||
if (menuPopup)
|
||||
menuPopup->SyncViewWithFrame(PR_TRUE);
|
||||
|
@ -288,7 +289,8 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
|||
// menuPopup->CaptureMouseEvents(PR_TRUE);
|
||||
}
|
||||
else {
|
||||
// Close the menu.
|
||||
// Close the menu.
|
||||
// XXX Execute the ondestroy handler
|
||||
mContent->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::open, PR_TRUE);
|
||||
if (child)
|
||||
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
|
@ -379,6 +381,33 @@ nsMenuFrame::Escape(PRBool& aHandledFlag)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuFrame::Enter()
|
||||
{
|
||||
if (!mMenuOpen) {
|
||||
// The enter key press applies to us.
|
||||
// XXX Execute the event handler.
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mContent->GetTag(*getter_AddRefs(tag));
|
||||
if (tag.get() == nsXULAtoms::xpmenuitem && mMenuParent) {
|
||||
// Close up the parent.
|
||||
mMenuParent->DismissChain();
|
||||
}
|
||||
else if (tag.get() == nsXULAtoms::xpmenuchildren) {
|
||||
OpenMenu(PR_TRUE);
|
||||
SelectFirstItem();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* frame = mPopupFrames.FirstChild();
|
||||
if (frame) {
|
||||
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
|
||||
popup->Enter();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuFrame::SelectFirstItem()
|
||||
{
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
void KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag);
|
||||
void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
|
||||
void Escape(PRBool& aHandledFlag);
|
||||
void Enter();
|
||||
|
||||
void ToggleMenuState();
|
||||
void SelectMenu(PRBool aActivateFlag);
|
||||
|
|
|
@ -390,6 +390,17 @@ nsMenuPopupFrame::Escape(PRBool& aHandledFlag)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuPopupFrame::Enter()
|
||||
{
|
||||
if (!mCurrentMenu)
|
||||
return;
|
||||
|
||||
// Give it to the child.
|
||||
nsMenuFrame* menuFrame = (nsMenuFrame*)mCurrentMenu;
|
||||
menuFrame->Enter();
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsMenuPopupFrame::FindMenuWithShortcut(PRUint32 aLetter)
|
||||
{
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
nsIFrame* FindMenuWithShortcut(PRUint32 aLetter);
|
||||
|
||||
void Escape(PRBool& aHandledFlag);
|
||||
void Enter();
|
||||
|
||||
protected:
|
||||
nsIFrame* mCurrentMenu; // The current menu that is active.
|
||||
|
|
Загрузка…
Ссылка в новой задаче