exposing drag and drop events to JS.

This commit is contained in:
pinkerton%netscape.com 1999-09-02 03:51:03 +00:00
Родитель 108bf34e41
Коммит e58a5c3434
8 изменённых файлов: 142 добавлений и 12 удалений

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

@ -45,8 +45,9 @@ static char* mEventNames[] = {
"mouseout", "mousemove", "keydown", "keyup", "keypress",
"focus", "blur", "load", "unload", "abort", "error",
"submit", "reset", "change", "select", "paint" ,"text",
"create", "destroy", "command"
};
"create", "destroy", "command", "dragenter", "dragover", "dragexit",
"dragdrop", "draggesture"
};
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
mPresContext = aPresContext;
@ -680,6 +681,16 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return mEventNames[eDOMEvents_destroy];
case NS_MENU_ACTION:
return mEventNames[eDOMEvents_action];
case NS_DRAGDROP_ENTER:
return mEventNames[eDOMEvents_dragenter];
case NS_DRAGDROP_OVER:
return mEventNames[eDOMEvents_dragover];
case NS_DRAGDROP_EXIT:
return mEventNames[eDOMEvents_dragexit];
case NS_DRAGDROP_DROP:
return mEventNames[eDOMEvents_dragdrop];
case NS_DRAGDROP_GESTURE:
return mEventNames[eDOMEvents_draggesture];
default:
break;
}

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

@ -61,7 +61,12 @@ public:
eDOMEvents_text,
eDOMEvents_create,
eDOMEvents_destroy,
eDOMEvents_action
eDOMEvents_action,
eDOMEvents_dragenter,
eDOMEvents_dragover,
eDOMEvents_dragexit,
eDOMEvents_dragdrop,
eDOMEvents_draggesture
};
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent);

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

@ -366,6 +366,26 @@ nsresult nsEventListenerManager::GetIdentifiersForType(const nsString& aType, ns
aIID = kIDOMMenuListenerIID;
*aFlags = NS_EVENT_BITS_MENU_ACTION;
}
else if (aType == "dragenter") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_ENTER;
}
else if (aType == "dragover") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_OVER;
}
else if (aType == "dragexit") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_EXIT;
}
else if (aType == "dragdrop") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_DROP;
}
else if (aType == "draggesture") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_GESTURE;
}
else {
return NS_ERROR_FAILURE;
}
@ -1049,7 +1069,33 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
NS_RELEASE(dragListener);
}
else {
ret = ls->mListener->HandleEvent(*aDOMEvent);
PRBool correctSubType = PR_FALSE;
switch(aEvent->message) {
case NS_DRAGDROP_ENTER:
if (ls->mSubType & NS_EVENT_BITS_DRAG_ENTER)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_OVER:
if (ls->mSubType & NS_EVENT_BITS_DRAG_OVER)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_EXIT:
if (ls->mSubType & NS_EVENT_BITS_DRAG_EXIT)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_DROP:
if (ls->mSubType & NS_EVENT_BITS_DRAG_DROP)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_GESTURE:
if (ls->mSubType & NS_EVENT_BITS_DRAG_GESTURE)
correctSubType = PR_TRUE;
break;
default:
break;
}
if (correctSubType || ls->mSubType == NS_EVENT_BITS_DRAG_NONE)
ret = ls->mListener->HandleEvent(*aDOMEvent);
}
}
}

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

@ -172,8 +172,11 @@ protected:
//nsIDOMDragListener
#define NS_EVENT_BITS_DRAG_NONE 0x00
#define NS_EVENT_BITS_DRAG_START 0x01
#define NS_EVENT_BITS_DRAG_DROP 0x02
#define NS_EVENT_BITS_DRAG_ENTER 0x01
#define NS_EVENT_BITS_DRAG_OVER 0x02
#define NS_EVENT_BITS_DRAG_EXIT 0x04
#define NS_EVENT_BITS_DRAG_DROP 0x08
#define NS_EVENT_BITS_DRAG_GESTURE 0x10
//nsIDOMPaintListener
#define NS_EVENT_BITS_PAINT_NONE 0x00

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

@ -45,8 +45,9 @@ static char* mEventNames[] = {
"mouseout", "mousemove", "keydown", "keyup", "keypress",
"focus", "blur", "load", "unload", "abort", "error",
"submit", "reset", "change", "select", "paint" ,"text",
"create", "destroy", "command"
};
"create", "destroy", "command", "dragenter", "dragover", "dragexit",
"dragdrop", "draggesture"
};
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent) {
mPresContext = aPresContext;
@ -680,6 +681,16 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return mEventNames[eDOMEvents_destroy];
case NS_MENU_ACTION:
return mEventNames[eDOMEvents_action];
case NS_DRAGDROP_ENTER:
return mEventNames[eDOMEvents_dragenter];
case NS_DRAGDROP_OVER:
return mEventNames[eDOMEvents_dragover];
case NS_DRAGDROP_EXIT:
return mEventNames[eDOMEvents_dragexit];
case NS_DRAGDROP_DROP:
return mEventNames[eDOMEvents_dragdrop];
case NS_DRAGDROP_GESTURE:
return mEventNames[eDOMEvents_draggesture];
default:
break;
}

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

@ -61,7 +61,12 @@ public:
eDOMEvents_text,
eDOMEvents_create,
eDOMEvents_destroy,
eDOMEvents_action
eDOMEvents_action,
eDOMEvents_dragenter,
eDOMEvents_dragover,
eDOMEvents_dragexit,
eDOMEvents_dragdrop,
eDOMEvents_draggesture
};
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent);

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

@ -366,6 +366,26 @@ nsresult nsEventListenerManager::GetIdentifiersForType(const nsString& aType, ns
aIID = kIDOMMenuListenerIID;
*aFlags = NS_EVENT_BITS_MENU_ACTION;
}
else if (aType == "dragenter") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_ENTER;
}
else if (aType == "dragover") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_OVER;
}
else if (aType == "dragexit") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_EXIT;
}
else if (aType == "dragdrop") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_DROP;
}
else if (aType == "draggesture") {
aIID = NS_GET_IID(nsIDOMDragListener);
*aFlags = NS_EVENT_BITS_DRAG_GESTURE;
}
else {
return NS_ERROR_FAILURE;
}
@ -1049,7 +1069,33 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext& aPresContext,
NS_RELEASE(dragListener);
}
else {
ret = ls->mListener->HandleEvent(*aDOMEvent);
PRBool correctSubType = PR_FALSE;
switch(aEvent->message) {
case NS_DRAGDROP_ENTER:
if (ls->mSubType & NS_EVENT_BITS_DRAG_ENTER)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_OVER:
if (ls->mSubType & NS_EVENT_BITS_DRAG_OVER)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_EXIT:
if (ls->mSubType & NS_EVENT_BITS_DRAG_EXIT)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_DROP:
if (ls->mSubType & NS_EVENT_BITS_DRAG_DROP)
correctSubType = PR_TRUE;
break;
case NS_DRAGDROP_GESTURE:
if (ls->mSubType & NS_EVENT_BITS_DRAG_GESTURE)
correctSubType = PR_TRUE;
break;
default:
break;
}
if (correctSubType || ls->mSubType == NS_EVENT_BITS_DRAG_NONE)
ret = ls->mListener->HandleEvent(*aDOMEvent);
}
}
}

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

@ -172,8 +172,11 @@ protected:
//nsIDOMDragListener
#define NS_EVENT_BITS_DRAG_NONE 0x00
#define NS_EVENT_BITS_DRAG_START 0x01
#define NS_EVENT_BITS_DRAG_DROP 0x02
#define NS_EVENT_BITS_DRAG_ENTER 0x01
#define NS_EVENT_BITS_DRAG_OVER 0x02
#define NS_EVENT_BITS_DRAG_EXIT 0x04
#define NS_EVENT_BITS_DRAG_DROP 0x08
#define NS_EVENT_BITS_DRAG_GESTURE 0x10
//nsIDOMPaintListener
#define NS_EVENT_BITS_PAINT_NONE 0x00