summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2019-03-07 03:56:19 (GMT)
committerKevin Walzer <kw@codebykevin.com>2019-03-07 03:56:19 (GMT)
commit537386f4a6d884537e64d0a994b375d97d5ccf10 (patch)
treee155a1632f76a8ede4a6919c4eefac0e2b5e53fc
parente7619b55d90b8d69afd4424ee4a897553a305427 (diff)
downloadtk-537386f4a6d884537e64d0a994b375d97d5ccf10.zip
tk-537386f4a6d884537e64d0a994b375d97d5ccf10.tar.gz
tk-537386f4a6d884537e64d0a994b375d97d5ccf10.tar.bz2
Clean up implementation and documentation of ::tk::mac::PrintDocument command; was mapped internally to ::tk::mac::OpenDocument and print event never fired; changed parameter to a single file path
-rw-r--r--doc/tk_mac.n5
-rw-r--r--macosx/tkMacOSXHLEvents.c17
2 files changed, 18 insertions, 4 deletions
diff --git a/doc/tk_mac.n b/doc/tk_mac.n
index b0aa36f..3762afc 100644
--- a/doc/tk_mac.n
+++ b/doc/tk_mac.n
@@ -117,9 +117,8 @@ proc ::tk::mac::OpenDocument {args} {
If a proc of this name is defined it is the default Apple Event handler for
kAEPrintDocuments,
.QW pdoc ,
-the Apple Event sent when your application is asked to print one or more
-documents (e.g., via the Print menu item in the Finder). It works the same
-way as \fBtk::mac::OpenDocument\fR in terms of arguments.
+the Apple Event sent when your application is asked to print a
+document. It takes a single absolute file path as an argument.
.TP
\fB::tk::mac::Quit\fR
.
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 0bd2d5e..d2843a8 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -126,9 +126,24 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
- tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::PrintDocument");
+
+ NSString* file = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ const char *printFile=[file UTF8String];
+ Tcl_DString print;
+ Tcl_DStringInit(&print);
+ if (Tcl_FindCommand(_eventInterp, "::tk::mac::PrintDocument", NULL, 0)) {
+ Tcl_DStringAppend(&print, "::tk::mac::PrintDocument", -1);
+ }
+ Tcl_DStringAppendElement(&print, printFile);
+ int tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&print),
+ Tcl_DStringLength(&print), TCL_EVAL_GLOBAL);
+ if (tclErr!= TCL_OK) {
+ Tcl_BackgroundException(_eventInterp, tclErr);
+ }
}
+
- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{