mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-28 09:13:08 +03:00
Accepting URLs dropped onto the browser view.
svn path=/trunk/netsurf/; revision=11900
This commit is contained in:
parent
905b230a3c
commit
f2bc0163c0
@ -59,6 +59,16 @@ static const CGFloat CaretWidth = 1.0;
|
||||
static const NSTimeInterval CaretBlinkTime = 0.8;
|
||||
static NSMutableArray *cocoa_reformat_pending = nil;
|
||||
|
||||
|
||||
- initWithFrame: (NSRect) frame;
|
||||
{
|
||||
if ((self = [super initWithFrame: frame]) == nil) return nil;
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects: NSURLPboardType, @"public.url", nil]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc;
|
||||
{
|
||||
[self setCaretTimer: nil];
|
||||
@ -580,4 +590,38 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
|
||||
[pb setString: [sender representedObject] forType: NSStringPboardType];
|
||||
}
|
||||
|
||||
|
||||
// MARK: -
|
||||
// MARK: Accepting dragged URLs
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
if ((NSDragOperationCopy | NSDragOperationGeneric) & [sender draggingSourceOperationMask]) {
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
|
||||
NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObjects: NSURLPboardType, @"public.url", nil]];
|
||||
|
||||
NSString *url = nil;
|
||||
if ([type isEqualToString: NSURLPboardType]) url = [[NSURL URLFromPasteboard: pb] absoluteString];
|
||||
else url = [pb stringForType: type];
|
||||
|
||||
browser_window_go( browser, [url UTF8String], NULL, true );
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user