From 2226c544308e29d27ccd042ea5acb8e4d2864727 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 15 May 2016 19:56:01 -0400 Subject: [PATCH] Made the font dialog respect our new modality rules on OS X. --- darwin/fontbutton.m | 19 +++++++++++++++++++ darwin/main.m | 2 ++ darwin/stddialogs.m | 2 +- darwin/uipriv_darwin.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/darwin/fontbutton.m b/darwin/fontbutton.m index ac3561fa..22bc6465 100644 --- a/darwin/fontbutton.m +++ b/darwin/fontbutton.m @@ -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 diff --git a/darwin/main.m b/darwin/main.m index e40c0616..bd939d4a 100644 --- a/darwin/main.m +++ b/darwin/main.m @@ -110,6 +110,8 @@ const char *uiInit(uiInitOptions *o) appDelegate().menuManager = [menuManager new]; [realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]]; + setupFontPanel(); + return NULL; } diff --git a/darwin/stddialogs.m b/darwin/stddialogs.m index 40f108c8..07f4ab03 100644 --- a/darwin/stddialogs.m +++ b/darwin/stddialogs.m @@ -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))) diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 6494e066..2bfaaf20 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -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);