Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add documentation on testing Mac services to README; remove obsolete detail from README; remove stub procedure for ::tk::mac::PerformService now that we have verified it works, to be consistent with other Mac-spdecific procedures such as ::tk::mac::OpenDocument |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | mac_services |
Files: | files | file ages | folders |
SHA3-256: |
356d52c7e3c27db3a8cd0c26b8a0a59f |
User & Date: | kevin_walzer 2019-05-20 02:33:01.069 |
Context
2019-05-20
| ||
13:21 | Edited README. Closed-Leaf check-in: a5d55621 user: culler tags: mac_services | |
02:33 | Add documentation on testing Mac services to README; remove obsolete detail from README; remove stub procedure for ::tk::mac::PerformService now that we have verified it works, to be consistent with other Mac-spdecific procedures such as ::tk::mac::OpenDocument check-in: 356d52c7 user: kevin_walzer tags: mac_services | |
2019-05-18
| ||
13:05 | Finally got timing of initializing NSServices object correct; code cleanup; merge in 8.6 to pick up changes in Tk initialization code check-in: f126b00e user: kevin_walzer tags: mac_services | |
Changes
Changes to doc/tk_mac.n.
︙ | ︙ | |||
152 153 154 155 156 157 158 | Executes a Tcl procedure called from the macOS .QW Services menu in the Application menu item. The .QW Services menu item allows for inter-application communication; data from one application, such as selected text, can be sent to another application for processing, for example to Safari as a search item for Google, or | | < | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | Executes a Tcl procedure called from the macOS .QW Services menu in the Application menu item. The .QW Services menu item allows for inter-application communication; data from one application, such as selected text, can be sent to another application for processing, for example to Safari as a search item for Google, or to TextEdit to be appended to a file. An example of the proc is below, and should be rewritten in an application script for customization: .RS .PP .CS proc ::tk::mac::PerformService {} { set data [clipboard get] $w insert end $data } |
︙ | ︙ |
Changes to library/tk.tcl.
︙ | ︙ | |||
677 678 679 680 681 682 683 | } # For now, turn off the custom mdef proc for the mac: if {[tk windowingsystem] eq "aqua"} { namespace eval ::tk::mac { set useCustomMDEF 0 | < < < < < < < < < | 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | } # For now, turn off the custom mdef proc for the mac: if {[tk windowingsystem] eq "aqua"} { namespace eval ::tk::mac { set useCustomMDEF 0 } } #register to send data to macOS Services if {[tk windowingsystem] eq "aqua"} { proc ::tk::RegisterServiceWidget {w} { ::tk::mac::registerServiceWidget $w |
︙ | ︙ |
Changes to macosx/README.
︙ | ︙ | |||
55 56 57 58 59 60 61 | $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks (searched in that order). Given a potential package directory $pkg, Tcl on OSX checks for the file $pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl. This allows building extensions as frameworks with all script files contained in the Resources/Scripts directory of the framework. | < < < < < | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks (searched in that order). Given a potential package directory $pkg, Tcl on OSX checks for the file $pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl. This allows building extensions as frameworks with all script files contained in the Resources/Scripts directory of the framework. - The 'deploy' target of macosx/GNUmakefile installs the html manpages into the standard documentation location in the Tcl/Tk frameworks: Tcl.framework/Resources/Documentation/Reference/Tcl Tk.framework/Resources/Documentation/Reference/Tk No nroff manpages are installed by default by the GNUmakefile. - The Tcl and Tk frameworks can be installed in any of the system's standard |
︙ | ︙ | |||
83 84 85 86 87 88 89 | - the env array is different when Wish is started from the Finder (i.e. via LaunchServices) than when it (or tclsh) is invoked from the Terminal, in particular PATH may not be what you expect. (Wish started by LaunchServices inherits loginwindow's environment variables, which are essentially those set in $HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell). | < < < < < < < < < < < < < < < < < < < < < < | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | - the env array is different when Wish is started from the Finder (i.e. via LaunchServices) than when it (or tclsh) is invoked from the Terminal, in particular PATH may not be what you expect. (Wish started by LaunchServices inherits loginwindow's environment variables, which are essentially those set in $HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell). - TkAqua provides access to native OS X images via the Tk native bitmap facility (including any image file readable by NSImage). A native bitmap name is interpreted as follows (in order): - predefined builtin 32x32 icon name (stop, caution, document, etc) - name defined by [tk::mac::iconBitmap] - NSImage named image name - NSImage url string |
︙ | ︙ | |||
332 333 334 335 336 337 338 | dialog window and the others match the contrasting background colors used in ttk::notebooks and ttk::labelframes which are nested to the corresponding depth. 5. Building Tcl/Tk on macOS ------------------------------ | < < | | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | dialog window and the others match the contrasting background colors used in ttk::notebooks and ttk::labelframes which are nested to the corresponding depth. 5. Building Tcl/Tk on macOS ------------------------------ - macOS 10.6 is required to build TkAqua and TkX11. The XCode application provides everything needed to build Tk, but it is not necessary to install the full XCode. It suffices to install the Command Line Tools package, which can be done by running the command: xcode-select --install - Tcl/Tk are most easily built as macOS frameworks via GNUmakefile in tcl/macosx and tk/macosx (see below for details), but can also be built with the standard unix configure and make buildsystem in tcl/unix resp. tk/unix as on any |
︙ | ︙ | |||
393 394 395 396 397 398 399 | the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to the project-relative paths '../../tcl' and '../../tk', if your source directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your ${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a text editor. | < < < < < < < < < < < | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to the project-relative paths '../../tcl' and '../../tk', if your source directories are named differently, e.g. '../../tcl8.6' and '../../tk8.6', you need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your ${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a text editor. - To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable to the minimal OS version the binaries should be able to run on, e.g: export MACOSX_DEPLOYMENT_TARGET=10.6 This requires at least gcc 3.1; with gcc 4 or later, set/add to CFLAGS instead: export CFLAGS="-mmacosx-version-min=10.6" Support for weak-linking was added with 8.4.14/8.5a5. |
︙ | ︙ | |||
708 709 710 711 712 713 714 | 10.14 supports system appearance changes, and has added a "Dark Mode" that casts all window frames and menus as black. Tk 8.6.9 has added two virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update your Tk app's appearance when the system appearance changes. Just bind your appearance-updating code to these virtual events and you will see it triggered when the system appearance toggles between dark and light. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | 10.14 supports system appearance changes, and has added a "Dark Mode" that casts all window frames and menus as black. Tk 8.6.9 has added two virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update your Tk app's appearance when the system appearance changes. Just bind your appearance-updating code to these virtual events and you will see it triggered when the system appearance toggles between dark and light. 7.0 Mac Services ~~~~~~~~~~~~~~~~~~~~~~~~~~~ With 8.6.10, Tk supports the Mac's NSServices API, documented at https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/introduction.html#//apple_ref/doc/uid/10000101-SW1 and in TIP 536 and Tk's man page. Tk presents a simple, straightforward API to implement the Services functionality, but testing and deploying can be a bit tricky. Apple's documents suggest running /System/Library/CoreServices/pbs -dump_pboard to check to see if your application's services have been recognized by the OS, but it may also be necessary to work with Apple's "lsregister" tool to ensure that the correct version of Wish has been picked up by the OS: First, run this command: alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister' Then, you can reset the launch services database used by the launch service like this: $ lsregister -kill $ lsregister -seed Then you can run this command to find out what will happen if you ask the launch service to launch Wish.app: lsregister -dump | grep path | grep Wish If the wrong version of Wish is showing up in this list, you can unregister that version as follows: alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister' You can reset the database used by the launch service like this: $ lsregister -kill $ lsregister -seed Then you can run this command to find out what will happen if you ask the launch service to launch Wish.app: lsregister -u /path/to/Wish Continue this until the correct version of Wish shows up in your path. This advice is focused mainly on testing the services you are developing for your application. From an end-user standpoint, the NSServices API is intended for standalone applications, such as one wrapped by the standalone version of Wish and re-named into a different application, so the complexities discussed above are not likely to be encountered by end users. |
Changes to macosx/tkMacOSXServices.c.
︙ | ︙ | |||
157 158 159 160 161 162 163 | int TkMacOSXRegisterServiceWidgetObjCmd ( ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) { | < < | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | int TkMacOSXRegisterServiceWidgetObjCmd ( ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) { /* * Need proper number of args. */ if(objc != 2) { Tcl_WrongNumArgs(ip, 1, objv, "path?"); return TCL_ERROR; |
︙ | ︙ | |||
206 207 208 209 210 211 212 | frame = NSMakeRect(bounds.left, bounds.top, 100000, 100000); frame.origin.y = 0; if (!NSEqualRects(frame, [serviceview frame])) { [serviceview setFrame:frame]; } [serviceview release]; | < < < < < < < | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | frame = NSMakeRect(bounds.left, bounds.top, 100000, 100000); frame.origin.y = 0; if (!NSEqualRects(frame, [serviceview frame])) { [serviceview setFrame:frame]; } [serviceview release]; return TCL_OK; } /* * Initalize the package in the Tcl interpreter, create Tcl commands. */ int TkMacOSXServices_Init( Tcl_Interp *interp) { /* * Initialize instance of TclServices to provide service functionality. */ TkService *service = [[TkService alloc] init]; ServicesInterp = interp; [NSApp setServicesProvider:service]; return TCL_OK; } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |