1
我正在通过mach_inject向Finder上下文菜单中添加项目来编写一个插件。我已经成功通过挂钩NSMenu添加它。但是现在我需要获取右键单击的项目。 有人说我们可以使用下面的代码,但它只能得到选择的项目而不是右键单击的项目(它们是不同的!!!!在Finder中,如果选择一个项目并右键单击另一个项目,则选定的项目将不会改变)。任何人都知道如何在Finder中右键单击项目?谢谢!如何在OSX上的Finder中右键单击文件项目
SBElementArray * selection = [[finder selection] get];
NSArray * items = [selection arrayByApplyingSelector:@selector(URL)];
for (NSString * item in items) {
NSURL * url = [NSURL URLWithString:item];
NSLog(@"selected item url: %@", url);
}
+1
你可以得到的文件,我也想知道这一点。 – livingtech