mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
More changes so DispatchEvent works
This commit is contained in:
parent
53ed2dcb22
commit
594b97f546
@ -118,13 +118,13 @@ nsWindow::~nsWindow()
|
||||
//-------------------------------------------------------------------------
|
||||
void nsWindow::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
|
||||
{
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
|
||||
{
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -1227,22 +1227,30 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus)
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsWindow::DispatchEvent(nsGUIEvent* event)
|
||||
NS_IMETHODIMP nsWindow::DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
event->widgetSupports = (nsISupports*)((nsObject*)this);
|
||||
|
||||
aStatus = nsEventStatus_eIgnore;
|
||||
if (nsnull != mEventCallback) {
|
||||
result = ConvertStatus((*mEventCallback)(event));
|
||||
}
|
||||
// Dispatch to event listener if event was not consumed
|
||||
if ((result != PR_TRUE) && (nsnull != mEventListener)) {
|
||||
result = ConvertStatus(mEventListener->ProcessEvent(*event));
|
||||
aStatus = (*mEventCallback)(event);
|
||||
}
|
||||
|
||||
// Dispatch to event listener if event was not consumed
|
||||
if ((aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener)) {
|
||||
aStatus = mEventListener->ProcessEvent(*event);
|
||||
}
|
||||
|
||||
return (result ? NS_OK : NS_ERROR_FAILURE);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
PRBool nsWindow::DispatchWindowEvent(nsGUIEvent* event)
|
||||
{
|
||||
nsEventStatus status;
|
||||
DispatchEvent(event, status);
|
||||
return ConvertStatus(status);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Deal with all sort of mouse event
|
||||
@ -1258,7 +1266,7 @@ PRBool nsWindow::DispatchMouseEvent(nsMouseEvent& aEvent)
|
||||
|
||||
// call the event callback
|
||||
if (nsnull != mEventCallback) {
|
||||
result = DispatchEvent(&aEvent) == NS_OK;
|
||||
result = DispatchWindowEvent(&aEvent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1331,7 +1339,7 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
|
||||
(void **)&event.renderingContext))
|
||||
{
|
||||
event.renderingContext->Init(mContext, this);
|
||||
result = DispatchEvent(&event) == NS_OK;
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
else
|
||||
@ -1368,7 +1376,7 @@ PRBool nsWindow::OnResize(nsSizeEvent &aEvent)
|
||||
nsRect* size = aEvent.windowSize;
|
||||
|
||||
if (mEventCallback && !mIgnoreResize) {
|
||||
return(DispatchEvent(&aEvent) == NS_OK);
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -1376,7 +1384,7 @@ PRBool nsWindow::OnResize(nsSizeEvent &aEvent)
|
||||
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent)
|
||||
{
|
||||
if (mEventCallback) {
|
||||
return(DispatchEvent(aEvent) == NS_OK);
|
||||
return DispatchWindowEvent(aEvent);
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
@ -1386,7 +1394,7 @@ PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEven
|
||||
PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent)
|
||||
{
|
||||
if (mEventCallback) {
|
||||
return(DispatchEvent(&aEvent) == NS_OK);
|
||||
return DispatchWindowEvent(&aEvent);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event);
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
||||
|
||||
virtual PRBool IsChild() { return(PR_FALSE); };
|
||||
|
||||
@ -157,7 +157,9 @@ public:
|
||||
|
||||
char gInstanceClassName[256];
|
||||
protected:
|
||||
void InitCallbacks(char * aName = nsnull);
|
||||
void InitCallbacks(char * aName = nsnull);
|
||||
PRBool DispatchWindowEvent(nsGUIEvent* event);
|
||||
|
||||
|
||||
void CreateGC();
|
||||
void CreateWindow(nsNativeWidget aNativeParent, nsIWidget *aWidgetParent,
|
||||
|
@ -681,7 +681,8 @@ void nsXtWidget_Menu_Callback(Widget w, XtPointer p, XtPointer call_data)
|
||||
|
||||
mevent.time = 0; //TBD
|
||||
|
||||
mevent.widget->DispatchEvent((nsGUIEvent *)&mevent);
|
||||
nsEventStatus status;
|
||||
mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
|
||||
|
||||
if (DBG) fprintf(stderr, "Out nsXtWidget_ExposureMask_EventHandler\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user