【发布时间】:2013-04-27 07:28:55
【问题描述】:
我的实用程序应用在另一个应用上执行文本编辑操作。 用户在 NSPanel 中设置参数并单击“确定”后,NSPanel 将关闭并迭代一个 while 循环,在目标应用程序中执行必要的文本编辑。
我想为用户提供使用 Command + . 停止操作的选项。 我不确定如何在循环迭代时检查用户是否按住键。
while 循环已简化。
- (IBAction)fileNameTrimAppend:(id)sender {
[self activateTargetApp]; // applescript that brings target app to front
[self openFileRenameDialog]; // applescript to open the file naming dialog
// set variables to use in the loop from the user input
[self close]; // close the input NSPanel
while ([self fileRenameDialogOpen]) { // applescript returns false when editing is done
if (command +"." is held down){ // need help here
return;
}
// text mod is done here.
// paste the mod text into target app field
// move to the next field for editing
}
}
【问题讨论】:
标签: objective-c macos cocoa