summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--library/entry.tcl12
-rw-r--r--library/text.tcl2
-rw-r--r--library/tk.tcl15
-rw-r--r--library/ttk/entry.tcl3
-rw-r--r--macosx/Wish-Info.plist.in7
-rw-r--r--macosx/tkMacOSXServices.c21
6 files changed, 47 insertions, 13 deletions
diff --git a/library/entry.tcl b/library/entry.tcl
index 780fcb2..3819832 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -75,6 +75,7 @@ bind Entry <<TraverseIn>> {
# Standard Motif bindings:
bind Entry <1> {
+ tk::RegisterServiceWidget %W
tk::EntryButton1 %W %x
%W selection clear
}
@@ -657,7 +658,7 @@ proc ::tk::EntryGetSelection {w} {
}
-if {[tk windowingsystem] eq "aqua"]{
+if {[tk windowingsystem] eq "aqua"} {
# ::tk::CheckEntrySelection --
#
# Writes selected text to the clipboard on macOS.
@@ -671,4 +672,13 @@ proc ::tk::CheckEntrySelection {w} {
clipboard append [::tk::EntryGetSelection $w]
}
}
+
}
+
+
+
+
+
+
+
+
diff --git a/library/text.tcl b/library/text.tcl
index c76153c..6c4c0f6 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -43,6 +43,7 @@
bind Text <1> {
tk::TextButton1 %W %x %y
%W tag remove sel 0.0 end
+ ::tk::RegisterServiceWidget %W
}
bind Text <B1-Motion> {
set tk::Priv(x) %x
@@ -400,7 +401,6 @@ bind Text <<Selection>> {
set selected [%W get sel.first sel.last]
clipboard append $selected
}
-
# End of Mac only bindings
}
diff --git a/library/tk.tcl b/library/tk.tcl
index d2f7b65..bda847d 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -682,6 +682,21 @@ if {[tk windowingsystem] eq "aqua"} {
namespace eval ::tk::mac {
set useCustomMDEF 0
}
+
+ #stub proc for NSServices API, must be replaced with custom implementation
+ proc ::tk::mac::PerformService {args} {
+
+ tk_messageBox -icon info -title "Services Example" -message "This data was sent to Wish with the NSServices API:\n\n$args"
+ }
+}
+
+#register to send data to macOS Services
+
+proc ::tk::RegisterServiceWidget {w} {
+
+if {[tk windowingsytem] eq "aqua"} {
+ ::tk::mac::registerServiceWidget $w
+ }
}
# Run the Ttk themed widget set initialization
diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl
index 7ac29e4..01ade97 100644
--- a/library/ttk/entry.tcl
+++ b/library/ttk/entry.tcl
@@ -348,6 +348,7 @@ proc ttk::entry::Press {w x} {
set State(x) $x
set State(selectMode) char
set State(anchor) [$w index insert]
+ ::tk::RegisterServiceWidget $w
}
## Shift-Press -- Shift-ButtonPress-1 binding.
@@ -607,7 +608,7 @@ proc ttk::entry::Delete {w} {
}
}
-if {[tk windowingsystem] eq "aqua"] {
+if {[tk windowingsystem] eq "aqua"} {
# ::ttk::CheckEntrySelection --
#
# Writes selected text to the clipboard on macOS.
diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in
index 0a22527..ef88997 100644
--- a/macosx/Wish-Info.plist.in
+++ b/macosx/Wish-Info.plist.in
@@ -79,16 +79,18 @@
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>NSServices</key>
- <array>
+ <array>
+ <dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
- <string>Wish: Run Tcl Script</string>
+ <string>Wish: Display Test Data</string>
</dict>
<key>NSMessage</key>
<string>provideService</string>
<key>NSPortName</key>
<string>Wish</string>
+
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
@@ -99,5 +101,6 @@
</array>
</dict>
</array>
+
</dict>
</plist>
diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c
index 00ec39f..cc4d282 100644
--- a/macosx/tkMacOSXServices.c
+++ b/macosx/tkMacOSXServices.c
@@ -26,7 +26,6 @@
#include <string.h>
static Tcl_Interp *ServicesInterp;
-char *myExportData[80];
/* These two assist with asynchronous Tcl proc calling. */
@@ -54,7 +53,7 @@ int ServicesEventProc(Tcl_Event *event, int flags) {
@end
/* Class methods. */
-@implementation TclService
+@implementation TkService
+ (void) initialize {
@@ -90,9 +89,9 @@ int ServicesEventProc(Tcl_Event *event, int flags) {
return NO;
}
- Tcl_Eval(Services_Interp,"clipboard get");
+ Tcl_Eval(ServicesInterp,"clipboard get");
char *copystring;
- copystring = Tcl_GetString(Tcl_GetObjResult(myInterp));
+ copystring = Tcl_GetString(Tcl_GetObjResult(ServicesInterp));
NSString *writestring = [NSString stringWithUTF8String:copystring];
typesDeclared = [NSArray arrayWithObject:NSStringPboardType];
@@ -112,7 +111,13 @@ int ServicesEventProc(Tcl_Event *event, int flags) {
}
returnText = [pboard stringForType:NSStringPboardType];
char *returnData = [returnText UTF8String];
- Tcl_Eval(Services_Interp,"clipboard clear; clipboard append %s", returnData);
+ Tcl_DString clip;
+ Tcl_DStringInit(&clip);
+ Tcl_DStringAppend(&clip, "clipboard clear; ", -1);
+ Tcl_DStringAppend(&clip, "clipboard append ", -1);
+ Tcl_DStringAppend(&clip, returnData, -1);
+ Tcl_Eval(ServicesInterp, &clip);
+ Tcl_DStringFree(&clip);
return YES;
}
@@ -139,8 +144,8 @@ int ServicesEventProc(Tcl_Event *event, int flags) {
/* Get output from service proc, return to interp, and write to pasteboard. */
char *output;
- output = Tcl_GetString(Tcl_GetObjResult(Services_Interp));
- Tcl_SetResult(Services_Interp, output, NULL);
+ output = Tcl_GetString(Tcl_GetObjResult(ServicesInterp));
+ Tcl_SetResult(ServicesInterp, output, NULL);
NSString *serviceOutput = [NSString stringWithUTF8String:output];
[pboard clearContents];
[pboard writeObjects:[NSArray arrayWithObject:serviceOutput]];
@@ -212,7 +217,7 @@ int Tk_MacOSXServices_Init (Tcl_Interp *interp) {
/* Initialize instance of TclServices to provide service functionality. */
TkService *service = [[TkService alloc] init];
- Service_Interp = interp;
+ ServicesInterp = interp;
[NSApp setServicesProvider:service];
[pool release];