зеркало из https://github.com/mozilla/pjs.git
Adding the capability to capture the mouse events.
This commit is contained in:
Родитель
4c79902e3a
Коммит
12c4edbf5f
|
@ -240,12 +240,17 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
|
||||||
nsCOMPtr<nsIContent> child;
|
nsCOMPtr<nsIContent> child;
|
||||||
GetMenuChildrenElement(getter_AddRefs(child));
|
GetMenuChildrenElement(getter_AddRefs(child));
|
||||||
|
|
||||||
|
nsIFrame* frame = mPopupFrames.FirstChild();
|
||||||
|
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
||||||
|
|
||||||
if (aActivateFlag) {
|
if (aActivateFlag) {
|
||||||
// Open the menu.
|
// Open the menu.
|
||||||
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
|
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
|
||||||
if (child)
|
if (child)
|
||||||
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||||
mMenuOpen = PR_TRUE;
|
mMenuOpen = PR_TRUE;
|
||||||
|
//if (menuPopup)
|
||||||
|
// menuPopup->CaptureMouseEvents(PR_TRUE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Close the menu.
|
// Close the menu.
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
nsresult NS_NewMenuFrame(nsIFrame** aResult) ;
|
nsresult NS_NewMenuFrame(nsIFrame** aResult) ;
|
||||||
|
|
||||||
class nsMenuBarFrame;
|
class nsMenuBarFrame;
|
||||||
|
class nsMenuPopupFrame;
|
||||||
|
|
||||||
class nsMenuFrame : public nsBoxFrame
|
class nsMenuFrame : public nsBoxFrame
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,6 +142,9 @@ nsMenuPopupFrame::Init(nsIPresContext& aPresContext,
|
||||||
&widgetData,
|
&widgetData,
|
||||||
nsnull);
|
nsnull);
|
||||||
|
|
||||||
|
// XXX: Don't need?
|
||||||
|
// ourView->SetViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,13 +325,43 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIContent* aMenuItem)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// Unset the current child.
|
// Unset the current child.
|
||||||
if (mCurrentMenu)
|
if (mCurrentMenu) {
|
||||||
|
printf("Unsetting current child.\n");
|
||||||
mCurrentMenu->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
mCurrentMenu->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
// Set the new child.
|
// Set the new child.
|
||||||
if (aMenuItem)
|
if (aMenuItem) {
|
||||||
|
printf("Setting new child.\n");
|
||||||
aMenuItem->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
aMenuItem->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||||
|
}
|
||||||
mCurrentMenu = aMenuItem;
|
mCurrentMenu = aMenuItem;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsMenuPopupFrame::CaptureMouseEvents(PRBool aGrabMouseEvents)
|
||||||
|
{
|
||||||
|
// get its view
|
||||||
|
nsIView* view = nsnull;
|
||||||
|
GetView(&view);
|
||||||
|
nsCOMPtr<nsIViewManager> viewMan;
|
||||||
|
PRBool result;
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
||||||
|
if (viewMan) {
|
||||||
|
if (aGrabMouseEvents) {
|
||||||
|
viewMan->GrabMouseEvents(view,result);
|
||||||
|
mIsCapturingMouseEvents = PR_TRUE;
|
||||||
|
} else {
|
||||||
|
viewMan->GrabMouseEvents(nsnull,result);
|
||||||
|
mIsCapturingMouseEvents = PR_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,11 @@ public:
|
||||||
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
|
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
|
||||||
nsresult SyncViewWithFrame(PRBool aOnMenuBar);
|
nsresult SyncViewWithFrame(PRBool aOnMenuBar);
|
||||||
|
|
||||||
|
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIContent* mCurrentMenu; // The current menu that is active.
|
nsIContent* mCurrentMenu; // The current menu that is active.
|
||||||
|
PRBool mIsCapturingMouseEvents; // Whether or not we're grabbing the mouse events.
|
||||||
}; // class nsMenuPopupFrame
|
}; // class nsMenuPopupFrame
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче