我有以下设置:
NSWindow 中的 4x4(总共 16 个)按钮(标准 NSButton 按钮)网格。
当我按下热键组合 (DDHotKey) 时 NSWindow 会出现在最前面
现在,我想做的是为我的按钮提供以下功能:
单击该按钮时,打开一个显示 /Applications/ 目录的对话框,并允许我选择其中列出的任何应用程序。
When the application is selected store it in a variable (I'm guessing) (or string?) and make it so that when the buttons Key Equivalent is pressed, that application launches
我环顾四周,我不确定该做什么或从哪里开始寻找……有什么线索吗?
我的 appdelegate.m 文件中有这个:
- (void)openDoc:(id)sender
{
int result;
NSArray *fileTypes = [NSArray arrayWithObject:@"td"];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setAllowsMultipleSelection:YES];
result = [oPanel runModalForDirectory:NSHomeDirectory()
file:nil types:fileTypes];
if (result == NSOKButton) {
NSArray *filesToOpen = [oPanel filenames];
int i, count = [filesToOpen count];
for (i=0; i<count; i++) {
NSString *aFile = [filesToOpen objectAtIndex:i];
id currentDoc = [[ToDoDoc alloc] initWithFile:aFile];
}
}
}
如何将按钮链接到它?