summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/console.n9
-rw-r--r--library/demos/unicodeout.tcl3
-rw-r--r--macosx/tkMacOSXDialog.c52
3 files changed, 49 insertions, 15 deletions
diff --git a/doc/console.n b/doc/console.n
index 1313d3a..86dbd46 100644
--- a/doc/console.n
+++ b/doc/console.n
@@ -25,9 +25,12 @@ the Tk library. Except for TkAqua, this command is not available when
Tk is loaded into a tclsh interpreter with
.QW "\fBpackage require Tk\fR" ,
as a conventional terminal is expected to be present in that case.
-In TkAqua, this command is only available when stdin is \fB/dev/null\fR
-(as is the case e.g. when the application embedding Tk is started
-from the Mac OS X Finder).
+In TkAqua, this command is disabled when there is a startup script
+and stdin is \fB/dev/null\fR (as is the case e.g. when a bundled application
+embedding Tk is started by the macOS Launcher). To enable the command
+in that case, define the environment variable \fBTK_CONSOLE\fR. This can be
+done by modifying the Info.plist file by adding the LSEnvironment key
+to the main dict and setting its value to be a dict with the key \fBTK_CONSOLE\fR.
.PP
.TP
\fBconsole eval \fIscript\fR
diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl
index bb4d8f8..759dc00 100644
--- a/library/demos/unicodeout.tcl
+++ b/library/demos/unicodeout.tcl
@@ -133,8 +133,7 @@ addSample $w Russian \
"\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A"
if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} {
if {[package vsatisfies [package provide Tcl] 8.7-]} {
- addSample $w Emoji \
- "\U1F600\U1F4A9\U1F44D\U1F1F3\U1F1F1"
+ addSample $w Emoji "😀💩👍🇳🇱"
} else {
addSample $w Emoji \
"\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1"
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 42cb4a5..40f4b12 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -23,7 +23,7 @@
#define modalOK NSModalResponseOK
#define modalCancel NSModalResponseCancel
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090
-#define modalOther -1
+#define modalOther -1 // indicates that the -command option was used.
#define modalError -2
/*
@@ -52,6 +52,10 @@ typedef struct {
* filter. */
} filepanelFilterInfo;
+/*
+ * Only one of these is needed for the application, so they can be static.
+ */
+
static filepanelFilterInfo filterInfo;
static NSOpenPanel *openpanel;
static NSSavePanel *savepanel;
@@ -250,13 +254,13 @@ getFileURL(
} else if (returnCode == modalCancel) {
Tcl_ResetResult(callbackInfo->interp);
}
- if (panel == [NSApp modalWindow]) {
- [NSApp stopModalWithCode:returnCode];
- }
if (callbackInfo->cmdObj) {
Tcl_DecrRefCount(callbackInfo->cmdObj);
+ }
+ if (callbackInfo) {
ckfree(callbackInfo);
}
+ [NSApp stopModalWithCode:returnCode];
}
- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
@@ -356,14 +360,42 @@ static NSInteger showOpenSavePanel(
contextInfo:callbackInfo ];
}];
- modalReturnCode = callbackInfo->cmdObj ? modalOther :
- [panel runModal];
+ /*
+ * The sheet has been prepared, so now we have to run it as a modal
+ * window. Using [NSApp runModalForWindow:] on macOS 10.15 or later
+ * generates warnings on stderr. But using [NSOpenPanel runModal] or
+ * [NSSavePanel runModal] on 10.14 or earler does not cause the
+ * completion handler to run when the panel is closed.
+ */
+
+ if ([NSApp macOSVersion] > 101400) {
+ modalReturnCode = [panel runModal];
+ } else {
+ modalReturnCode = [NSApp runModalForWindow:panel];
+ }
} else {
- modalReturnCode = [panel runModal];
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
- contextInfo:callbackInfo];
+
+ /*
+ * For the standalone file dialog, completion handlers do not work
+ * at all on macOS 10.14 and earlier.
+ */
+
+ if ([NSApp macOSVersion] > 101400) {
+ [panel beginWithCompletionHandler:^(NSModalResponse returnCode) {
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:returnCode
+ contextInfo:callbackInfo ];
+ }];
+ modalReturnCode = [panel runModal];
+ } else {
+ modalReturnCode = [panel runModal];
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:modalReturnCode
+ contextInfo:callbackInfo ];
+ [panel close];
+ }
}
- return modalReturnCode;
+ return callbackInfo->cmdObj ? modalOther : modalReturnCode;
}
/*