public DragEventSource(long pointerId, NSDraggingInfo draggingInfo, NSWindow window) { Id = pointerId; _macOSDraggingInfo = draggingInfo; _window = window; }
[Export("performDragOperation:")] // Do not remove internal virtual bool PerformDragOperation(NSDraggingInfo draggingInfo) { try { return(PerformDragOperationAction.Invoke(draggingInfo)); } catch { return(false); } }
[Export("draggingUpdated:")] // Do not remove internal virtual NSDragOperation DraggingUpdated(NSDraggingInfo draggingInfo) { try { return(DraggingUpdatedAction.Invoke(draggingInfo)); } catch { return(NSDragOperation.None); } }
[Export("draggingExited:")] // Do not remove internal virtual void DraggingExited(NSDraggingInfo draggingInfo) { try { DraggingExitedAction.Invoke(draggingInfo); } catch { // Simply return if an error occurred, it is unrecoverable } return; }
private NSDragOperation OnDraggingEnteredEvent(NSDraggingInfo draggingInfo) { var source = new DragEventSource(_fakePointerId, draggingInfo, _window); var data = DataPackage.CreateFromNativeDragDropData(draggingInfo); var allowedOperations = DataPackageOperation.Copy; // Should match with return value var info = new CoreDragInfo(source, data, allowedOperations); CoreDragDropManager.GetForCurrentView()?.DragStarted(info); // Note: No need to _manager.ProcessMove, the DragStarted will actually have the same effect // To allow the macOS drag to continue, we must assume drop is supported here. // This will immediately be updated within the OnDraggingUpdated method. return(NSDragOperation.Copy); }
private void OnDraggingEnded(NSDraggingInfo draggingInfo) { return; }
private bool OnPerformDragOperation(NSDraggingInfo draggingInfo) { var operation = _manager.ProcessDropped(new DragEventSource(_fakePointerId, draggingInfo, _window)); return(operation != DataPackageOperation.None); }
private void OnDraggingExited(NSDraggingInfo draggingInfo) { _ = _manager.ProcessAborted(new DragEventSource(_fakePointerId, draggingInfo, _window)); return; }
private NSDragOperation OnDraggingUpdated(NSDraggingInfo draggingInfo) { var operation = _manager.ProcessMoved(new DragEventSource(_fakePointerId, draggingInfo, _window)); return(ToNSDragOperation(operation)); }
[Export("prepareForDragOperation:")] // Do not remove internal virtual bool PrepareForDragOperation(NSDraggingInfo draggingInfo) { // Always return true as UWP doesn't really have an equivalent step. // Drop is accepted within DraggingEntered (drag entered event in UWP). return(true); }
internal static DataPackageView CreateFromNativeDragDropData(NSDraggingInfo draggingInfo) { return(GetFromNative(draggingInfo.DraggingPasteboard)); }