可可应用程序中不调用事件
这是一个头文件:
@interface MainDreamer : NSWindow <NSWindowDelegate>
{
IBOutlet NSTextField *myField;
IBOutlet NSTableView *myTable;
IBOutlet NSImageView *myView;
IBOutlet NSMutableArray *mylist;
IBOutlet NSMutableArray *dataset;
}
- (IBAction)addRecord:(id)sender;
- (IBAction)deleterecord:(id)sender;
@property (assign) IBOutlet NSWindow *window;
@end
我在 .m 文件中实现了几个事件:
- (void) mouseDown:(NSEvent *)theEvent{
NSLog(@"mouse down");
}
- (void) mouseUp:(NSEvent *)theEvent{
NSLog(@"mouse up");
}
- (void) tableViewSelectionDidChange: (NSNotification *) notification{
NSLog(@"selected row changed");
}
- (BOOL) acceptsFirstResponder{
return YES;
}
但是它们都没有被调用(我通过放置断点来检查它)。
程序中的其他方法工作正常,包括,因此所有带有电线的东西似乎都可以。
为什么事件处理程序不启动?
Here's a header file:
@interface MainDreamer : NSWindow <NSWindowDelegate>
{
IBOutlet NSTextField *myField;
IBOutlet NSTableView *myTable;
IBOutlet NSImageView *myView;
IBOutlet NSMutableArray *mylist;
IBOutlet NSMutableArray *dataset;
}
- (IBAction)addRecord:(id)sender;
- (IBAction)deleterecord:(id)sender;
@property (assign) IBOutlet NSWindow *window;
@end
I implemented several events in .m file:
- (void) mouseDown:(NSEvent *)theEvent{
NSLog(@"mouse down");
}
- (void) mouseUp:(NSEvent *)theEvent{
NSLog(@"mouse up");
}
- (void) tableViewSelectionDidChange: (NSNotification *) notification{
NSLog(@"selected row changed");
}
- (BOOL) acceptsFirstResponder{
return YES;
}
However neither of them are invoked (I checked it by putting in a breakpoint).
Other methods in the program work fine including, so everything with wires seems to be OK.
Why don't the events handlers launch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您转到 xib 文件并单击窗口,“自定义类”类型设置为什么?
NSWindow
或MainDreamer
。事实上,它没有命中您的任何方法,这告诉我它仍然设置为 NSWindow。尝试将“自定义类”设置为
MainDreamer
并看看会发生什么。If you go to your xib file and click on your window, what is the "Custom Class" type set to?
NSWindow
orMainDreamer
.The fact it's not hitting any of your methods tells me it's still set to
NSWindow
. Try setting your "Custom Class" toMainDreamer
and see what happens then.