Drag&Drop XamMac
Bert1974 opened this issue · comments
All kind off problems.. ViewBackend.InitPastBoard/FillDataStore don't support all data types.
and also DragFinished event isn't fired
and a xamarin problem most of the time conversion from NSObject to NSDraggingInfo fails,
working on it, for the xamarin problem part of my code below, it skips NSDraggingInfo and gets the needed values through NSObject,GetDictionaryOfValuesFromKeys, and it uses ConvertPointToView to get (seems) the dragposition correctly for childwidgets in childwidgets.
private static void GetDragInfoFromNSObject(ViewBackend backend, IntPtr dragInfo, out Point pt, out NSPasteboard pb, out NSDragOperation dragop)
{
var d = Runtime.GetNSObject(dragInfo).GetDictionaryOfValuesFromKeys(new NSString[] { (NSString)"draggingPasteboard", (NSString)"draggingSourceOperationMask", (NSString)"draggingLocation" });
pb = d[(NSString)"draggingPasteboard"] as NSPasteboard;
var oo = d[(NSString)"draggingSourceOperationMask"];
dragop = (NSDragOperation)(int)oo.GetType().GetProperty("Int32Value").GetValue(oo, new object[0]);
oo = d[(NSString)"draggingLocation"];
pt = ConvertDragPointToXwt(backend, (CGPoint)oo.GetType().GetProperty("CGPointValue").GetValue(oo, new object[0]));
}
private static Point ConvertDragPointToXwt(ViewBackend backend, CGPoint cgpt)
{
var wp = backend.Widget.ConvertPointToView(new CGPoint(0, 0), backend.Widget.Window.ContentView);
return new Point(cgpt.X - wp.X, wp.Y - cgpt.Y);
}