mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-21 02:23:17 +08:00
ENH: [STUDIO-3911] web view drag drop on macOS
Change-Id: I92e7f6135152e4bfaf7f7342cdff1ea2e269c5a5 (cherry picked from commit 3452e6edebeecf499d44798ff6b85425ab244cb4)
This commit is contained in:
parent
d30470d603
commit
e7598e6406
@ -97,6 +97,7 @@ void WKWebView_setTransparentBackground(void * web)
|
|||||||
{
|
{
|
||||||
WKWebView * webView = (WKWebView*)web;
|
WKWebView * webView = (WKWebView*)web;
|
||||||
[webView layer].backgroundColor = [NSColor clearColor].CGColor;
|
[webView layer].backgroundColor = [NSColor clearColor].CGColor;
|
||||||
|
[webView registerForDraggedTypes: @[NSFilenamesPboardType]];
|
||||||
}
|
}
|
||||||
|
|
||||||
void openFolderForFile(wxString const & file)
|
void openFolderForFile(wxString const & file)
|
||||||
@ -110,6 +111,54 @@ void openFolderForFile(wxString const & file)
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/* WKWebView */
|
||||||
|
@implementation WKWebView (DragDrop)
|
||||||
|
|
||||||
|
+ (void) load
|
||||||
|
{
|
||||||
|
Method draggingEntered = class_getInstanceMethod([WKWebView class], @selector(draggingEntered:));
|
||||||
|
Method draggingEntered2 = class_getInstanceMethod([WKWebView class], @selector(draggingEntered2:));
|
||||||
|
method_exchangeImplementations(draggingEntered, draggingEntered2);
|
||||||
|
|
||||||
|
Method draggingUpdated = class_getInstanceMethod([WKWebView class], @selector(draggingUpdated:));
|
||||||
|
Method draggingUpdated2 = class_getInstanceMethod([WKWebView class], @selector(draggingUpdated2:));
|
||||||
|
method_exchangeImplementations(draggingUpdated, draggingUpdated2);
|
||||||
|
|
||||||
|
Method prepareForDragOperation = class_getInstanceMethod([WKWebView class], @selector(prepareForDragOperation:));
|
||||||
|
Method prepareForDragOperation2 = class_getInstanceMethod([WKWebView class], @selector(prepareForDragOperation2:));
|
||||||
|
method_exchangeImplementations(prepareForDragOperation, prepareForDragOperation2);
|
||||||
|
|
||||||
|
Method performDragOperation = class_getInstanceMethod([WKWebView class], @selector(performDragOperation:));
|
||||||
|
Method performDragOperation2 = class_getInstanceMethod([WKWebView class], @selector(performDragOperation2:));
|
||||||
|
method_exchangeImplementations(performDragOperation, performDragOperation2);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDragOperation)draggingEntered2:(id<NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
return NSDragOperationCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDragOperation)draggingUpdated2:(id<NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
return NSDragOperationCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)prepareForDragOperation2:(id<NSDraggingInfo>)info
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)performDragOperation2:(id<NSDraggingInfo>)info
|
||||||
|
{
|
||||||
|
NSURL* url = [NSURL URLFromPasteboard:[info draggingPasteboard]];
|
||||||
|
NSString * path = [url path];
|
||||||
|
url = [NSURL fileURLWithPath: path];
|
||||||
|
[self loadFileURL:url allowingReadAccessToURL:url];
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
/* textColor for NSTextField */
|
/* textColor for NSTextField */
|
||||||
@implementation NSTextField (textColor)
|
@implementation NSTextField (textColor)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user