summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
{