【发布时间】:2012-08-27 10:44:23
【问题描述】:
我正在为我想要使用 NSFontPanel 的应用程序创建一个功能。 我不想在我的应用程序中有“字体”菜单。
单击菜单项时打开和关闭字体面板是这样完成的
- (IBAction) showOverlayControls:(id)sender
{
if ( [[NSFontPanel sharedFontPanel] isVisible])
{
NSLog(@"Test");
[[NSFontPanel sharedFontPanel] orderOut:self];
}
else
{
NSFontManager* fontMgr = [NSFontManager sharedFontManager];
[fontMgr setTarget:self];
NSFontPanel* fontPanel = [NSFontPanel sharedFontPanel];
[fontPanel orderFront:self];
}
}
它工作正常。 当我尝试在应用程序启动时关闭字体面板以防显示时出现问题。我试过了
if ( [[NSFontPanel sharedFontPanel] isVisible] )
[[NSFontPanel sharedFontPanel] close];
或
if ( [[NSFontPanel sharedFontPanel] isVisible] )
[[NSFontPanel sharedFontPanel] orderOut:self];
我也尝试过不使用 if 语句,但仍然没有运气。 如果在应用程序关闭时显示面板,则在应用程序打开时它总是会再次弹出。 我还尝试在我的应用委托的 appWillTerminate 方法中关闭字体面板。 同样的行为。
希望有任何提示。 提前致谢,
弗洛
【问题讨论】:
标签: objective-c cocoa nswindow nspanel