0
我使用此源http://www.cats.rwth-aachen.de/library/programming/cocoa无法点击按钮
创建我的自定义工作表。
我创建在现有的.xib文件NSPanel
对象,并使用IBOutlet
我的源代码连接:
.H
@interface MainDreamer : NSWindow <NSWindowDelegate>
{
...
NSPanel *newPanel;
}
...
@property (assign) IBOutlet NSPanel *newPanel;
的.m
@dynamic newPanel;
...
//this method is wired with button on main window and calls a sheet
- (IBAction)callPanel:(id)sender
{
[NSApp beginSheet:newPanel
modalForWindow:[self window] modalDelegate:self
didEndSelector:@selector(myPanelDidEnd:returnCode:contextInfo:)
contextInfo: nil]; //(__bridge void *)[NSNumber numberWithFloat: 0]
}
//this method is wired with cancel and ok buttons on the panel
- (IBAction)endWorkPanel:(id)sender
{
[newPanel orderOut:self];
[NSApp endSheet:newPanel returnCode:([sender tag] == 9) ? NSOKButton : NSCancelButton];
}
//closing a sheet
- (void)myPanelDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSCancelButton) return;
else{
return;
}
}
所以callPanel
工作正常,工作表出现,但我无法与工作表上的控件(带按钮)进行交互。他们不会对点击产生反应(甚至直观)。
问题出在哪里?