Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Drag&Drop XamMac #943

Open
Bert1974 opened this issue Jun 5, 2019 · 0 comments
Open

Drag&Drop XamMac #943

Bert1974 opened this issue Jun 5, 2019 · 0 comments

Comments

@Bert1974
Copy link

Bert1974 commented Jun 5, 2019

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);
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant