【发布时间】:2013-10-22 11:42:36
【问题描述】:
我创建了简单的 cocoa 应用程序。我在其中使用 NSOutlineView。现在我的任务是让 Escape Key 被按下。在我的 appdelegate.m 中,我为 NSOutlineView 实现了所有 require 方法。
【问题讨论】:
标签: objective-c macos cocoa nsoutlineview
我创建了简单的 cocoa 应用程序。我在其中使用 NSOutlineView。现在我的任务是让 Escape Key 被按下。在我的 appdelegate.m 中,我为 NSOutlineView 实现了所有 require 方法。
【问题讨论】:
标签: objective-c macos cocoa nsoutlineview
SubClass 你的 NSOutlineView 并将它的按键按下事件捕获为:
- (void)keyDown:(NSEvent *)theEvent
{
switch([theEvent keyCode])
{
case 53: // esc
NSLog(@"ESC");
// Implement the functionality you want when esc is pressed
break;
default:
[super keyDown:theEvent];
}
}
【讨论】:
好吧,您可以找出是否按下了转义键,尝试在下面一行并在您的方法中需要它的地方使用:-
NSUInteger flags = [theEvent keycode];
//After that
If (flags==53)
{
NSlog(@"Escape key pressed");
}
【讨论】: