-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// DragImageFileView.h | ||
// PlayEm | ||
// | ||
// Created by Till Toenshoff on 14.03.24. | ||
// Copyright © 2024 Till Toenshoff. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol DragImageFileViewDelegate <NSObject> | ||
- (BOOL)performDragOperationWithURL:(NSURL*)url; | ||
@end | ||
|
||
@interface DragImageFileView : NSImageView | ||
@property (nonatomic, weak) IBOutlet id<DragImageFileViewDelegate> delegate; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// DragImageFileView.m | ||
// PlayEm | ||
// | ||
// Created by Till Toenshoff on 14.03.24. | ||
// Copyright © 2024 Till Toenshoff. All rights reserved. | ||
// | ||
|
||
#import "DragImageFileView.h" | ||
|
||
@implementation DragImageFileView | ||
|
||
- (void)drawRect:(NSRect)dirtyRect { | ||
[super drawRect:dirtyRect]; | ||
|
||
// Drawing code here. | ||
} | ||
|
||
#pragma mark - Drag & Drop | ||
|
||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender | ||
{ | ||
NSPasteboard* pboard = [sender draggingPasteboard]; | ||
NSDragOperation sourceDragMask = [sender draggingSourceOperationMask]; | ||
|
||
if ( [[pboard types] containsObject:NSPasteboardTypeFileURL] ) { | ||
if (sourceDragMask & NSDragOperationGeneric) { | ||
return NSDragOperationGeneric; | ||
} else if (sourceDragMask & NSDragOperationLink) { | ||
return NSDragOperationLink; | ||
} else if (sourceDragMask & NSDragOperationCopy) { | ||
return NSDragOperationCopy; | ||
} | ||
} | ||
return NSDragOperationNone; | ||
} | ||
|
||
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender | ||
{ | ||
return YES; | ||
} | ||
|
||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender | ||
{ | ||
NSPasteboard* pboard = [sender draggingPasteboard]; | ||
|
||
if (pboard.pasteboardItems.count <= 1) { | ||
NSURL* url = [NSURL URLFromPasteboard:pboard]; | ||
if (url) { | ||
return [_delegate performDragOperationWithURL:url]; | ||
} | ||
} | ||
return NO; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters