自定义工作表:无法单击按钮 [英] Custom Sheet : can't click buttons
问题描述
我使用此来源 http://www.cats.rwth-aachen。 de / library / programming / cocoa
创建我的自定义工作表。
to create my custom sheet.
NSPanel
现有.xib文件中的对象,并与 IBOutlet
I created a NSPanel
object in existing .xib file and connected with 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
工作正常,工作表出现,但我不能与工作表上的控件交互(使用按钮)。
So callPanel
works fine, sheet appears but I can't interact with controls on the sheet (with buttons). They don't react on a click (even visually).
问题出在哪里?
推荐答案
他忘记了
[newDreamPanel close];
我写了它,因为我希望主窗口启动时不出现面板。
in applicationDidFinishLaunching
method. I wrote it because I wanted the panel to not appear when main window launches.
事实上,可见启动
面板的属性应在IB中激活。 close
方法也起作用,但副作用是所有控件在面板上无法显示。
In fact, the Visible At Launch
panel's property should be activated in IB. The close
method works too, but side effect is that all controls become unable on the panel.
这篇关于自定义工作表:无法单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!