0
  1. 创建新的 10.8 项目。
  2. 在此代码之后的 Appdelegate.m

    • (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // 在此处插入代码以初始化您的应用程序 }

我加

- (void)mouseDown:(NSEvent *)event{

    NSLog(@"Hi");

}

但我没有触发事件

我的问题是我应该在 Appdelegate.m 中做什么,以便当用户单击 Window 时触发 mouseDown 事件?

4

1 回答 1

0
  1. Create a subclass of NSView. Then just paste that code in the .m file.
  2. Click on your Xib window. Open Document Outline drawer and make sure that its View is selected. Then go to the sidebar to the right and click on the identity inspector. Then enter the name of the subclass you've created in the Class field.

That's much it.

于 2013-11-08T19:09:14.123 回答