This commit is contained in:
hyatt%netscape.com 1999-07-23 08:36:39 +00:00
Родитель 612bd6cedd
Коммит dafe020a98
8 изменённых файлов: 64 добавлений и 17 удалений

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

@ -35,7 +35,10 @@ public:
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult) = 0;
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult) = 0;
NS_IMETHOD SetActive() = 0;
NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
};
#endif

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

@ -35,7 +35,10 @@ public:
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult) = 0;
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult) = 0;
NS_IMETHOD SetActive() = 0;
NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
};
#endif

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

@ -116,9 +116,9 @@ nsMenuBarFrame::Init(nsIPresContext& aPresContext,
}
NS_IMETHODIMP
nsMenuBarFrame::SetActive()
nsMenuBarFrame::SetActive(PRBool aActiveFlag)
{
mIsActive = PR_TRUE;
mIsActive = aActiveFlag;
return NS_OK;
}
@ -138,7 +138,7 @@ nsMenuBarFrame::ToggleMenuActiveState()
}
else {
// Activate the menu bar
SetActive();
SetActive(PR_TRUE);
// Set the active menu to be the top left item (e.g., the File menu).
// We use an attribute called "active" to track the current active menu.
@ -384,7 +384,14 @@ nsMenuBarFrame::Escape()
nsMenuFrame* menuFrame = (nsMenuFrame*)mCurrentMenu;
if (menuFrame->IsOpen()) {
// Let the child menu handle this.
menuFrame->Escape();
PRBool handled = PR_FALSE;
menuFrame->Escape(handled);
if (!handled) {
// Close up this menu but keep our current menu item
// designation.
menuFrame->OpenMenu(PR_FALSE);
}
return;
}
// It's us. Just set our active flag to false.

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

@ -45,7 +45,9 @@ public:
NS_IMETHOD SetCurrentMenuItem(nsIFrame* aMenuItem);
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult);
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult);
NS_IMETHOD SetActive();
NS_IMETHOD SetActive(PRBool aActiveFlag);
NS_IMETHOD GetIsActive(PRBool& isActive) { isActive = IsActive(); return NS_OK; };
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) { isMenuBar = PR_TRUE; return NS_OK; };
NS_IMETHOD IsActive() { return mIsActive; };

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

@ -194,12 +194,25 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext,
if (frame) {
// We have children.
ToggleMenuState();
if (!IsOpen() && mMenuParent) {
// We closed up. The menu bar should always be
// deactivated when this happens.
mMenuParent->SetActive(PR_FALSE);
}
}
}
else if (aEvent->message == NS_MOUSE_EXIT) {
// Deactivate the menu.
if (mMenuParent && !mMenuOpen)
mMenuParent->SetCurrentMenuItem(nsnull);
PRBool isActive = PR_FALSE;
PRBool isMenuBar = PR_FALSE;
if (mMenuParent) {
mMenuParent->IsMenuBar(isMenuBar);
if (isMenuBar) {
mMenuParent->GetIsActive(isActive);
if (!isActive)
mMenuParent->SetCurrentMenuItem(nsnull);
}
}
}
else if (aEvent->message == NS_MOUSE_MOVE) {
// Let the menu parent know we're the new item.
@ -258,7 +271,7 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
// Tell the menu bar we're active.
mMenuParent->SetActive();
mMenuParent->SetActive(PR_TRUE);
}
mMenuOpen = PR_TRUE;
@ -348,10 +361,13 @@ nsMenuFrame::KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag)
}
void
nsMenuFrame::Escape()
nsMenuFrame::Escape(PRBool& aHandledFlag)
{
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
popup->Escape(aHandledFlag);
}
}
void

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

@ -79,7 +79,7 @@ public:
void KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag);
void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
void Escape();
void Escape(PRBool& aHandledFlag);
void ToggleMenuState();
void SelectMenu(PRBool aActivateFlag);

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

@ -371,9 +371,23 @@ nsMenuPopupFrame::CaptureMouseEvents(PRBool aGrabMouseEvents)
}
void
nsMenuPopupFrame::Escape()
nsMenuPopupFrame::Escape(PRBool& aHandledFlag)
{
if (!mCurrentMenu)
return;
// See if our menu is open.
nsMenuFrame* menuFrame = (nsMenuFrame*)mCurrentMenu;
if (menuFrame->IsOpen()) {
// Let the child menu handle this.
menuFrame->Escape(aHandledFlag);
if (!aHandledFlag) {
// We should close up.
menuFrame->OpenMenu(PR_FALSE);
aHandledFlag = PR_TRUE;
}
return;
}
}
nsIFrame*

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

@ -46,7 +46,9 @@ public:
NS_IMETHOD SetCurrentMenuItem(nsIFrame* aMenuItem);
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult);
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult);
NS_IMETHOD SetActive() { return NS_OK; }; // We don't care.
NS_IMETHOD SetActive(PRBool aActiveFlag) { return NS_OK; }; // We don't care.
NS_IMETHOD GetIsActive(PRBool& isActive) { isActive = PR_FALSE; return NS_OK; };
NS_IMETHOD IsMenuBar(PRBool& isMenuBar) { isMenuBar = PR_FALSE; return NS_OK; };
// Overridden methods
NS_IMETHOD Init(nsIPresContext& aPresContext,
@ -68,7 +70,7 @@ public:
void ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag);
nsIFrame* FindMenuWithShortcut(PRUint32 aLetter);
void Escape();
void Escape(PRBool& aHandledFlag);
protected:
nsIFrame* mCurrentMenu; // The current menu that is active.