Made the font dialog respect our new modality rules on OS X.

This commit is contained in:
Pietro Gagliardi 2016-05-15 19:56:01 -04:00
parent 1db3027619
commit 2226c54430
4 changed files with 23 additions and 1 deletions

View File

@ -168,6 +168,25 @@ BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override)
return YES;
}
// we also don't want the panel to be usable when there's a dialog running; see stddialogs.m for more details on that
// unfortunately the panel seems to ignore -setWorksWhenModal: so we'll have to do things ourselves
@interface nonModalFontPanel : NSFontPanel
@end
@implementation nonModalFontPanel
- (BOOL)worksWhenModal
{
return NO;
}
@end
void setupFontPanel(void)
{
[NSFontManager setFontPanelFactory:[nonModalFontPanel class]];
}
static void defaultOnChanged(uiFontButton *b, void *data)
{
// do nothing

View File

@ -110,6 +110,8 @@ const char *uiInit(uiInitOptions *o)
appDelegate().menuManager = [menuManager new];
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
setupFontPanel();
return NULL;
}

View File

@ -3,7 +3,7 @@
// TODO restructure this whole file
// TODO explicitly document this works as we want
// TODO explicitly disable font and color dialogs this way
// TODO explicitly disable color dialogs this way
#define windowWindow(w) ((NSWindow *) uiControlHandle(uiControl(w)))

View File

@ -109,3 +109,4 @@ extern void doDrawText(CGContextRef c, CGFloat cheight, double x, double y, uiDr
// fontbutton.m
extern BOOL fontButtonInhibitSendAction(SEL sel, id from, id to);
extern BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override);
extern void setupFontPanel(void);