From 4a976d45762201f2dbe979a2df648e97dc7d0924 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Wed, 11 Mar 2015 09:42:11 +1100 Subject: Update drag and drop to use current APIs instead of deprecated APIs. --- cocoa/ScintillaView.mm | 63 +++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'cocoa/ScintillaView.mm') diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index d5f658755..13dd1d4f9 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -730,6 +730,45 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- +/** + * Implement NSDraggingSource. + */ + +- (NSDragOperation)draggingSession: (NSDraggingSession *) session +sourceOperationMaskForDraggingContext: (NSDraggingContext) context +{ + switch(context) + { + case NSDraggingContextOutsideApplication: + return NSDragOperationCopy | NSDragOperationMove | NSDragOperationDelete; + + case NSDraggingContextWithinApplication: + default: + return NSDragOperationCopy | NSDragOperationMove | NSDragOperationDelete; + } +} + +- (void)draggingSession:(NSDraggingSession *)session + movedToPoint:(NSPoint)screenPoint +{ +} + +- (void)draggingSession:(NSDraggingSession *)session + endedAtPoint:(NSPoint)screenPoint + operation:(NSDragOperation)operation +{ + if (operation == NSDragOperationDelete) + { + mOwner.backend->WndProc(SCI_CLEAR, 0, 0); + } +} + +/** + * Implement NSDraggingDestination. + */ + +//-------------------------------------------------------------------------------------------------- + /** * Called when an external drag operation enters the view. */ @@ -775,30 +814,6 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- -/** - * Returns operations we allow as drag source. - */ -- (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL) isLocal -{ -// Scintilla does not choose different operations for other applications -#pragma unused(isLocal) - return NSDragOperationCopy | NSDragOperationMove | NSDragOperationDelete; -} - -//-------------------------------------------------------------------------------------------------- - -/** - * Finished a drag: may need to delete selection. - */ - -- (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation { - if (operation == NSDragOperationDelete) { - mOwner.backend->WndProc(SCI_CLEAR, 0, 0); - } -} - -//-------------------------------------------------------------------------------------------------- - /** * Drag operation is done. Notify editor. */ -- cgit v1.2.3