Implement 'drop-files' tray event on OS X.
This commit is contained in:
parent
2cd6ad1a97
commit
d342c9a6df
7 changed files with 49 additions and 4 deletions
|
@ -41,6 +41,8 @@ const CGFloat kMargin = 3;
|
|||
kStatusItemLength,
|
||||
[[statusItem_ statusBar] thickness]);
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
[self registerForDraggedTypes:
|
||||
[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
|
||||
[statusItem_ setView:self];
|
||||
}
|
||||
return self;
|
||||
|
@ -174,6 +176,24 @@ const CGFloat kMargin = 3;
|
|||
trayIcon_->NotifyRightClicked([self getBoundsFromEvent:event]);
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
|
||||
NSPasteboard* pboard = [sender draggingPasteboard];
|
||||
|
||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
std::vector<std::string> dropFiles;
|
||||
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
for (NSString* file in files)
|
||||
dropFiles.push_back(base::SysNSStringToUTF8(file));
|
||||
trayIcon_->NotfiyDropFiles(dropFiles);
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)shouldHighlight {
|
||||
BOOL is_menu_open = [menuController_ isMenuOpen];
|
||||
return isHighlightEnable_ && (inMouseEventSequence_ || is_menu_open);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue