int 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());  OS.SetDragAllowableActions(theDrag[0], operations, true);   OS.SetDragAllowableActions(theDrag[0], OS.kDragActionNothing, false);  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]);
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());  OS.SetDragAllowableActions(theDrag[0], operations, true);   OS.SetDragAllowableActions(theDrag[0], OS.kDragActionNothing, false);  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);
private void drag(Event dragEvent) {	DNDEvent event = new DNDEvent();	event.widget = this;		event.time = dragEvent.time;	event.doit = true;	try {		notifyListeners(DND.DragStart, event);	} catch (Throwable e) {		return;	}	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; 		try {			notifyListeners(DND.DragEnd, event);		} catch (Throwable e) {}		return;	}		Point pt = new Point();	OS.GetGlobalMouse (pt);		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;		// Immediately get data for transfer.  On other platforms, we wait	// until the data is requested, but on the mac, particularly in the case of files,	// we need to know how many items are being transferred when registering.  	// The only way to know this is to get the data.	int index = 0;	for (int i = 0; i < transferAgents.length; i++) {		int[] types = transferAgents[i].getTypeIds();		for (int j = 0; j < types.length; j++) {			TransferData transferData = new TransferData();			transferData.type = types[j];			event = new DNDEvent();			event.widget = this;			event.time = (int)System.currentTimeMillis(); 			event.dataType = transferData; 			try {				notifyListeners(DND.DragSetData, event);			} catch (Throwable e) {				continue;			}			if (event.data == null) continue;			transferAgents[i].javaToNative(event.data, transferData);			if (transferData.result != OS.noErr || transferData.data == null) continue; 			for (int k = 0; k < transferData.data.length; k++) {				byte[] data = transferData.data[k];				OS.AddDragItemFlavor(theDrag[0], index++, types[j], data, data.length, 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; 		try {			notifyListeners(DND.DragEnd, event);		} catch (Throwable e) {}		return;	}		int 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);	// until the interaction with Finder is understood, only allow data to be	// transferred internally	OS.SetDragAllowableActions(theDrag[0], OS.kDragActionNothing, false);		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; 	try {		notifyListeners(DND.DragEnd, event);	} catch (Throwable e) {}				OS.DisposeRgn(theRegion);	OS.DisposeDrag(theDrag[0]);}