зеркало из https://github.com/mozilla/pjs.git
More fun with menus.
This commit is contained in:
Родитель
1c2b36a081
Коммит
efe3a93b89
|
@ -30,6 +30,8 @@
|
|||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsMenuFrame.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIViewManager.h"
|
||||
|
||||
//
|
||||
// NS_NewMenuBarFrame
|
||||
|
@ -113,6 +115,13 @@ nsMenuBarFrame::Init(nsIPresContext& aPresContext,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuBarFrame::SetActive()
|
||||
{
|
||||
mIsActive = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsMenuBarFrame::ToggleMenuActiveState()
|
||||
{
|
||||
|
@ -129,7 +138,7 @@ nsMenuBarFrame::ToggleMenuActiveState()
|
|||
}
|
||||
else {
|
||||
// Activate the menu bar
|
||||
mIsActive = PR_TRUE;
|
||||
SetActive();
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
NS_IMETHOD SetCurrentMenuItem(nsIFrame* aMenuItem);
|
||||
NS_IMETHOD GetNextMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
||||
NS_IMETHOD GetPreviousMenuItem(nsIFrame* aStart, nsIFrame** aResult);
|
||||
NS_IMETHOD SetActive() { mIsActive = PR_TRUE; return NS_OK; };
|
||||
NS_IMETHOD SetActive();
|
||||
|
||||
NS_IMETHOD IsActive() { return mIsActive; };
|
||||
|
||||
|
|
|
@ -191,9 +191,6 @@ nsMenuFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
nsIFrame* frame = mPopupFrames.FirstChild();
|
||||
if (frame) {
|
||||
// We have children.
|
||||
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
|
||||
PRBool onMenuBar = PR_TRUE;
|
||||
popup->SyncViewWithFrame(onMenuBar);
|
||||
ToggleMenuState();
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +241,11 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
|||
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
||||
|
||||
if (aActivateFlag) {
|
||||
|
||||
// Sync up the view.
|
||||
if (menuPopup)
|
||||
menuPopup->SyncViewWithFrame(PR_TRUE);
|
||||
|
||||
// Open the menu.
|
||||
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
|
||||
if (child) {
|
||||
|
@ -264,6 +266,10 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
|||
if (child)
|
||||
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
mMenuOpen = PR_FALSE;
|
||||
|
||||
// Make sure we clear out our own items.
|
||||
if (menuPopup)
|
||||
menuPopup->SetCurrentMenuItem(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ protected:
|
|||
protected:
|
||||
nsFrameList mPopupFrames;
|
||||
PRBool mMenuOpen;
|
||||
nsMenuBarFrame* mMenuBar;
|
||||
nsIMenuParent* mMenuParent; // Our parent menu.
|
||||
}; // class nsMenuFrame
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче