我有以下设置:
在一个NSButton中由4x4 (总共16个)按钮(标准NSWindow按钮)组成的网格。
当我按下热键组合( NSWindow )时,DDHotKey就会出现在前面。
现在,我要做的是给我的按钮以下功能:
单击
。
我环顾四周,不知道该怎么做,也不知道从哪里开始looking...any线索?
我在我的应用程序委托文件中有这个:
- (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];
}
}
}我怎么把按钮连接到它上?
发布于 2011-05-13 21:36:50
您可以使用NSOpenPanel来选择应用程序。
然后,要启动应用程序,请查看this堆栈溢出问题。
发布于 2011-05-13 21:38:08
存储应用程序的路径,然后当您想打开它们时。您可以使用system()函数。
system("open -a /Applications/someApplication.app");https://stackoverflow.com/questions/5998008
复制相似问题