Adding the capability to capture the mouse events.

This commit is contained in:
hyatt%netscape.com 1999-07-21 08:51:41 +00:00
Родитель af934abd81
Коммит 4fd2eb41cc
4 изменённых файлов: 45 добавлений и 3 удалений

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

@ -240,12 +240,17 @@ nsMenuFrame::OpenMenu(PRBool aActivateFlag)
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
if (aActivateFlag) {
// Open the menu.
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::open, "true", PR_TRUE);
if (child)
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
mMenuOpen = PR_TRUE;
//if (menuPopup)
// menuPopup->CaptureMouseEvents(PR_TRUE);
}
else {
// Close the menu.

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

@ -34,6 +34,7 @@
nsresult NS_NewMenuFrame(nsIFrame** aResult) ;
class nsMenuBarFrame;
class nsMenuPopupFrame;
class nsMenuFrame : public nsBoxFrame
{

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

@ -142,6 +142,9 @@ nsMenuPopupFrame::Init(nsIPresContext& aPresContext,
&widgetData,
nsnull);
// XXX: Don't need?
// ourView->SetViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
return rv;
}
@ -322,13 +325,43 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIContent* aMenuItem)
return NS_OK;
// Unset the current child.
if (mCurrentMenu)
if (mCurrentMenu) {
printf("Unsetting current child.\n");
mCurrentMenu->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
}
// Set the new child.
if (aMenuItem)
if (aMenuItem) {
printf("Setting new child.\n");
aMenuItem->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
}
mCurrentMenu = aMenuItem;
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);
nsresult SyncViewWithFrame(PRBool aOnMenuBar);
NS_IMETHOD CaptureMouseEvents(PRBool aGrabMouseEvents);
protected:
nsIContent* mCurrentMenu; // The current menu that is active.
PRBool mIsCapturingMouseEvents; // Whether or not we're grabbing the mouse events.
}; // class nsMenuPopupFrame
#endif