I'm creating a feature for my application where I want to use the NSFontPanel. I don't want to have a "Font" menu in my application.
Opening and closing the font panel when a menu item is clicked is done like that
- (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];
}
}
It works ok. The problem arises when I try to close the font panel on application launch in case it is shown. I tried around with
if ( [[NSFontPanel sharedFontPanel] isVisible] )
[[NSFontPanel sharedFontPanel] close];
or
if ( [[NSFontPanel sharedFontPanel] isVisible] )
[[NSFontPanel sharedFontPanel] orderOut:self];
I also tried it without the if statement, still no luck. If the panel is shown when the app is closed, it always pops up again when the app is opened. I also tried to close the font panel in the appWillTerminate method of my app delegate. Same behavior.
Would appreciate any hints. Thanks in advance,
Flo