return the event handling status correctly from DispatchEvent on child views, more event handling cleanup in our menu impl. b=396520 r=cbarrett sr=roc a=roc

This commit is contained in:
joshmoz%gmail.com 2007-09-19 22:15:48 +00:00
Родитель 9cf30e3d8e
Коммит 0a621b7ab7
5 изменённых файлов: 14 добавлений и 38 удалений

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

@ -1311,7 +1311,7 @@ NS_IMETHODIMP nsChildView::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
}
// Invokes callback and ProcessEvent method on Event Listener object
// Invokes callback and ProcessEvent methods on Event Listener object
NS_IMETHODIMP nsChildView::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
{
aStatus = nsEventStatus_eIgnore;
@ -1344,7 +1344,7 @@ NS_IMETHODIMP nsChildView::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStat
// dispatch to event listener if event was not consumed
if (mEventListener && aStatus != nsEventStatus_eConsumeNoDefault)
mEventListener->ProcessEvent(*event);
aStatus = mEventListener->ProcessEvent(*event);
return NS_OK;
}

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

@ -932,7 +932,7 @@ NS_IMETHODIMP nsCocoaWindow::ResetInputState()
}
// Invokes callback and ProcessEvent method on Event Listener object
// Invokes callback and ProcessEvent methods on Event Listener object
NS_IMETHODIMP
nsCocoaWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
{
@ -940,16 +940,15 @@ nsCocoaWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
nsIWidget* aWidget = event->widget;
NS_IF_ADDREF(aWidget);
if (nsnull != mMenuListener){
if(NS_MENU_EVENT == event->eventStructType)
aStatus = mMenuListener->MenuSelected(static_cast<nsMenuEvent&>(*event));
}
if (mMenuListener && event->eventStructType == NS_MENU_EVENT)
aStatus = mMenuListener->MenuSelected(static_cast<nsMenuEvent&>(*event));
if (mEventCallback)
aStatus = (*mEventCallback)(event);
// Dispatch to event listener if event was not consumed
if ((aStatus != nsEventStatus_eConsumeNoDefault) && (mEventListener != nsnull))
if (mEventListener && aStatus != nsEventStatus_eConsumeNoDefault)
aStatus = mEventListener->ProcessEvent(*event);
NS_IF_RELEASE(aWidget);

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

@ -136,15 +136,6 @@ nsMenuBarX::~nsMenuBarX()
nsEventStatus
nsMenuBarX::MenuItemSelected(const nsMenuEvent &aMenuEvent)
{
for (PRInt32 i = mMenusArray.Count() - 1; i >= 0; i--) {
nsCOMPtr<nsIMenu> menu = mMenusArray.ObjectAt(i);
nsCOMPtr<nsIMenuListener> menuListener = do_QueryInterface(menu);
if (menuListener) {
nsEventStatus eventStatus = menuListener->MenuItemSelected(aMenuEvent);
if (eventStatus != nsEventStatus_eIgnore)
return eventStatus;
}
}
return nsEventStatus_eIgnore;
}
@ -152,17 +143,6 @@ nsMenuBarX::MenuItemSelected(const nsMenuEvent &aMenuEvent)
nsEventStatus
nsMenuBarX::MenuSelected(const nsMenuEvent &aMenuEvent)
{
for (PRInt32 i = mMenusArray.Count() - 1; i >= 0; i--) {
nsCOMPtr<nsIMenu> menu = mMenusArray.ObjectAt(i);
nsCOMPtr<nsIMenuListener> thisListener = do_QueryInterface(menu);
if (thisListener) {
//TODO: MenuSelected is the right thing to call...
//eventStatus = menuListener->MenuSelected(aMenuEvent);
nsEventStatus eventStatus = thisListener->MenuItemSelected(aMenuEvent);
if (eventStatus != nsEventStatus_eIgnore)
return eventStatus;
}
}
return nsEventStatus_eIgnore;
}

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

@ -255,8 +255,7 @@ NS_METHOD nsMenuItemX::IsSeparator(PRBool & aIsSep)
nsEventStatus nsMenuItemX::MenuItemSelected(const nsMenuEvent & aMenuEvent)
{
// this is all handled by Carbon Events
return nsEventStatus_eConsumeNoDefault;
return nsEventStatus_eIgnore;
}

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

@ -444,15 +444,13 @@ NS_IMETHODIMP nsMenuX::RemoveMenuListener(nsIMenuListener * aMenuListener)
nsEventStatus nsMenuX::MenuItemSelected(const nsMenuEvent & aMenuEvent)
{
// all this is now handled by Carbon Events.
return nsEventStatus_eConsumeNoDefault;
return nsEventStatus_eIgnore;
}
nsEventStatus nsMenuX::MenuSelected(const nsMenuEvent & aMenuEvent)
{
// printf("JOSH: MenuSelected called for %s \n", NS_LossyConvertUTF16toASCII(mLabel).get());
nsEventStatus eventStatus = nsEventStatus_eIgnore;
// Determine if this is the correct menu to handle the event
MenuRef selectedMenuHandle = (MenuRef)aMenuEvent.mCommand;
@ -479,7 +477,7 @@ nsEventStatus nsMenuX::MenuSelected(const nsMenuEvent & aMenuEvent)
OnCreated(); // Now that it's built, fire the popupShown event.
eventStatus = nsEventStatus_eConsumeNoDefault;
return nsEventStatus_eConsumeNoDefault;
}
else {
// Make sure none of our submenus are the ones that should be handling this
@ -487,14 +485,14 @@ nsEventStatus nsMenuX::MenuSelected(const nsMenuEvent & aMenuEvent)
nsISupports* menuSupports = mMenuItemsArray.ObjectAt(i);
nsCOMPtr<nsIMenuListener> menuListener = do_QueryInterface(menuSupports);
if (menuListener) {
eventStatus = menuListener->MenuSelected(aMenuEvent);
if (nsEventStatus_eIgnore != eventStatus)
nsEventStatus eventStatus = menuListener->MenuSelected(aMenuEvent);
if (eventStatus != nsEventStatus_eIgnore)
return eventStatus;
}
}
}
return eventStatus;
return nsEventStatus_eIgnore;
}