for (int j = 0; j < types.length; j++) { OS.AddDragItemFlavor(theDrag[0], index++, types[j], null, 0, 0); } }  if (index == 0) { OS.DisposeDrag(theDrag[0]); event = new DNDEvent(); event.widget = this; event.time = (int)System.currentTimeMillis(); event.doit = false; event.detail = DND.DROP_NONE; notifyListeners(DND.DragEnd, event); return;
if (transferAgents[i] instanceof FileTransfer) { TransferData transferData = new TransferData(); transferData.type = types[0]; event = new DNDEvent(); event.widget = this; event.time = (int)System.currentTimeMillis(); event.dataType = transferData; notifyListeners(DND.DragSetData, event); if (event.data == null) return; Transfer transferAgent = transferAgents[i]; for (int j = 0; j < types.length; j++) { transferData.type = types[j]; transferAgent.javaToNative(event.data, transferData); if (transferData.result != OS.noErr) return; for (int k = 0; k < transferData.data.length; k++) { byte[] datum = transferData.data[k]; OS.AddDragItemFlavor(theDrag[0], 1 + k, types[j], datum, datum.length, 0); } } } else { for (int j = 0; j < types.length; j++) { OS.AddDragItemFlavor(theDrag[0], 1, types[j], null, 0, 0); } }
private void drag(Event dragEvent) {	DNDEvent event = new DNDEvent();	event.widget = this;		event.time = dragEvent.time;	event.doit = true;	notifyListeners(DND.DragStart, event);	if (!event.doit || transferAgents == null || transferAgents.length == 0) return;		int[] theDrag = new int[1];	if (OS.NewDrag(theDrag) != OS.noErr) {		event = new DNDEvent();		event.widget = this;		event.time = (int)System.currentTimeMillis();		event.doit = false;		event.detail = DND.DROP_NONE; 		notifyListeners(DND.DragEnd, event);		return;	}		Point pt = new Point();	OS.GetGlobalMouse (pt);		int index = 0;	for (int i = 0; i < transferAgents.length; i++) {		int[] types = transferAgents[i].getTypeIds();		for (int j = 0; j < types.length; j++) {			OS.AddDragItemFlavor(theDrag[0], index++, types[j], null, 0, 0);			}		}	if (index == 0) {		OS.DisposeDrag(theDrag[0]);		event = new DNDEvent();		event.widget = this;		event.time = (int)System.currentTimeMillis();		event.doit = false;		event.detail = DND.DROP_NONE; 		notifyListeners(DND.DragEnd, event);		return;	}		OS.SetDragSendProc(theDrag[0], DragSendDataProc.getAddress(), control.handle);		int theRegion = 0;	try {			theRegion = OS.NewRgn();		OS.SetRectRgn(theRegion, (short)(pt.h-10), (short)(pt.v-10), (short)(pt.h+10), (short)(pt.v+10));				int operations = opToOsOp(getStyle());		//set operations twice - local and not local		OS.SetDragAllowableActions(theDrag[0], operations, true);		OS.SetDragAllowableActions(theDrag[0], operations, false);				EventRecord theEvent = new EventRecord();		theEvent.message = OS.kEventMouseMoved;		theEvent.modifiers = (short)OS.GetCurrentEventKeyModifiers();		theEvent.what = (short)OS.osEvt;		theEvent.where_h = (short)pt.h;		theEvent.where_v = (short)pt.v;			int result = OS.TrackDrag(theDrag[0], theEvent, theRegion);				int operation = DND.DROP_NONE;		if (result == OS.noErr) { 			int[] outAction = new int[1];			OS.GetDragDropAction(theDrag[0], outAction);			operation = osOpToOp(outAction[0]);		}				event = new DNDEvent();		event.widget = this;		event.time = (int)System.currentTimeMillis();		event.doit = result == OS.noErr;		event.detail = operation; 		notifyListeners(DND.DragEnd, event);	} finally {			if (theRegion != 0) OS.DisposeRgn(theRegion);	}	OS.DisposeDrag(theDrag[0]);}