1tk::mac(n)                   Tk Built-In Commands                   tk::mac(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tk::mac - Access Mac-Specific Functionality on OS X from Tk
9

SYNOPSIS

11       ::tk::mac::DoScriptFile
12       ::tk::mac::DoScriptText
13       ::tk::mac::ShowPreferences
14       ::tk::mac::OpenApplication
15       ::tk::mac::ReopenApplication
16       ::tk::mac::OpenDocument file...
17       ::tk::mac::PrintDocument file...
18       ::tk::mac::Quit
19       ::tk::mac::OnHide
20       ::tk::mac::OnShow
21       ::tk::mac::ShowHelp
22       ::tk::mac::PerformService
23       ::tk::mac::LaunchURL URL...
24       ::tk::mac::GetAppPath
25
26       ::tk::mac::standardAboutPanel
27
28       ::tk::mac::useCompatibilityMetrics boolean
29       ::tk::mac::CGAntialiasLimit limit
30       ::tk::mac::antialiasedtext number
31       ::tk::mac::useThemedToplevel boolean
32
33
34       ::tk::mac::iconBitmap name width height -kind value
35______________________________________________________________________________
36

EVENT HANDLER CALLBACKS

38       The  Aqua/Mac  OS  X  application environment defines a number of addi‐
39       tional events that applications should respond  to.  These  events  are
40       mapped  by  Tk  to calls to commands in the ::tk::mac namespace; unless
41       otherwise noted, if the command is absent, no action will be taken.
42
43       ::tk::mac::DoScriptFile
44              The default Apple Event handler for AEDoScriptHandler. This com‐
45              mand executes a Tcl file when an AppleScript sends a “do script”
46              command to Wish with a file path as a parameter.
47
48       ::tk::mac::DoScriptText
49              The default Apple Event handler for AEDoScriptHandler. This com‐
50              mand  executes  Tcl code when an AppleScript sends a “do script”
51              command to Wish with Tcl code or a Tcl procedure as a parameter.
52
53       ::tk::mac::ShowPreferences
54              The default Apple Event handler for kAEShowPreferences,  “pref”.
55              The  application  menu  “Preferences”  menu item is only enabled
56              when this proc is defined. Typically this  command  is  used  to
57              wrap a specific own preferences command, which pops up a prefer‐
58              ences window. Something like:
59
60                     proc ::tk::mac::ShowPreferences {} {
61                         setPref
62                     }
63
64       ::tk::mac::OpenApplication
65              If a proc of this name is defined, this proc fill fire when your
66              application  is  initially opened. It is the default Apple Event
67              handler for kAEOpenApplication, “oapp”.
68
69       ::tk::mac::ReopenApplication
70              If a proc of this name is defined it is the default Apple  Event
71              handler  for  kAEReopenApplication, “rapp”, the Apple Event sent
72              when your application is opened when it is already running (e.g.
73              by  clicking its icon in the Dock). Here is a sample that raises
74              a minimized window when the Dock icon is clicked:
75
76                     proc ::tk::mac::ReopenApplication {} {
77                         if {[wm state .] eq "withdrawn"} {
78                             wm state . normal
79                         } else {
80                             wm deiconify .
81                         }
82                         raise .
83                     }
84
85       ::tk::mac::OpenDocument file...
86              If a proc of this name is defined it is the default Apple  Event
87              handler  for kAEOpenDocuments, “odoc”, the Apple Event sent when
88              your application is asked to open one or more  documents  (e.g.,
89              by  drag  & drop onto the app or by opening a document of a type
90              associated to the app). The proc should take as arguments  paths
91              to the files to be opened, like so:
92
93                     proc ::tk::mac::OpenDocument {args} {
94                         foreach f $args {my_open_document $f}
95                     }
96
97       ::tk::mac::PrintDocument file...
98              If  a proc of this name is defined it is the default Apple Event
99              handler for kAEPrintDocuments, “pdoc”, the Apple Event sent when
100              your  application is asked to print a document.  It takes a sin‐
101              gle absolute file path as an argument.
102
103       ::tk::mac::Quit
104              If a proc of this name is defined it is the default Apple  Event
105              handler  for  kAEQuitApplication,  “quit”,  the Apple Event sent
106              when your application is asked to be quit,  e.g.  via  the  quit
107              menu  item  in  the  application menu, the quit menu item in the
108              Dock menu, or during a logout/restart/shutdown etc. If  this  is
109              not defined, exit is called instead.
110
111       ::tk::mac::OnHide
112              If  defined,  this  is  called  when your application receives a
113              kEventAppHidden event, e.g. via the hide menu item in the appli‐
114              cation or Dock menus.
115
116       ::tk::mac::OnShow
117              If  defined,  this  is  called  when your application receives a
118              kEventAppShown event, e.g. via the show all  menu  item  in  the
119              application  menu,  or  by  clicking  the  Dock icon of a hidden
120              application.
121
122       ::tk::mac::ShowHelp
123              Customizes behavior of Apple Help menu; if this procedure is not
124              defined,  the platform-specific standard Help menu item “YourApp
125              Help” performs the default Cocoa action of showing the Help Book
126              configured  in  the  application's  Info.plist (or displaying an
127              alert if no Help Book is set).
128
129       ::tk::mac::PerformService
130              Executes a Tcl procedure called from the macOS  “Services”  menu
131              in  the  Application  menu item. The “Services” menu item allows
132              for inter-application communication; data from one  application,
133              such  as  selected  text, can be sent to another application for
134              processing, for example to Safari as a search item  for  Google,
135              or  to TextEdit to be appended to a file. An example of the proc
136              is below, and should be rewritten in an application  script  for
137              customization:
138
139                     proc ::tk::mac::PerformService {} {
140                         set data [clipboard get]
141                         $w insert end $data
142                     }
143       Note  that the mechanism for retrieving the data is from the clipboard;
144       there is no other supported way to obtain the data.   If  the  Services
145       process  is  not  desired,  the NSServices keys can be deleted from the
146       application's Info.plist file. The underlying code supporting this com‐
147       mand  also allows the text, entry and ttk::entry widgets to access ser‐
148       vices from other applications via the Services menu. The NSPortName key
149       in  Wish's  Info.plist file is currently set as “Wish” ; if a developer
150       changes the name of the Wish executable to something
151         else, this key should be modified with the same name.
152
153       ::tk::mac::LaunchURL URL...
154              If defined, launches a URL within Tk. This would be used if a Tk
155              application  wants  to  handle  a URL itself, such as displaying
156              data from an RSS feed, rather than launching a default  applica‐
157              tion  to  handle  the URL, although it can defined as such. Wish
158              includes a stub URL scheme of “foo://” in the CFBundleURLSchemes
159              key  of  its  Info.plist file; this should be customized for the
160              specific URL scheme the developer wants to support.
161
162       ::tk::mac::GetAppPath
163              Returns the current applications's file path.
164
165
166
167
168       ADDITIONAL DIALOGS
169
170       The Aqua/Mac OS X defines additional dialogs that  applications  should
171       support.
172
173       ::tk::mac::standardAboutPanel
174              Brings the standard Cocoa about panel to the front, with all its
175              information filled in from your application bundle files  (stan‐
176              dard  about panel with no options specified). See Apple Technote
177              TN2179 and the AppKit documentation for  -[NSApplication  order‐
178              FrontStandardAboutPanelWithOptions:]    for   details   on   the
179              Info.plist keys and app bundle files used by the about panel.
180

SYSTEM CONFIGURATION

182       There are a number of additional global configuration options that con‐
183       trol the details of how Tk renders by default.
184
185       ::tk::mac::useCompatibilityMetrics boolean
186              Preserves compatibility with older Tk/Aqua metrics; set to false
187              for more native spacing.
188
189       ::tk::mac::CGAntialiasLimit limit
190              Sets the antialiasing limit; lines  thinner  that  limit  pixels
191              will  not  be  antialiased. Integer, set to 0 by default, making
192              all lines be antialiased.
193
194       ::tk::mac::antialiasedtext number
195              Sets anti-aliased text.  Controls  text  antialiasing,  possible
196              values  for  number are -1 (default, use system default for text
197              AA), 0 (no text AA), 1 (use text AA).
198
199       ::tk::mac::useThemedToplevel boolean
200              Sets toplevel windows to draw with the modern grayish/ pinstripe
201              Mac  background.  Equivalent  to  configuring  the toplevel with
202-background  systemWindowHeaderBackground”,  or  to   using   a
203              ttk::frame.
204

SUPPORT COMMANDS

206       ::tk::mac::iconBitmap name width height -kind value
207              Renders  native  icons and bitmaps in Tk applications (including
208              any image file readable by NSImage). A  native  bitmap  name  is
209              interpreted as follows (in order):
210
211              ·  predefined  builtin 32x32 icon name (stop, caution, document,
212                 etc.)
213
214              ·  name, as defined by tk::mac::iconBitmap
215
216              ·  NSImage named image name
217
218              ·  NSImage url string
219
220              ·  4-char OSType of IconServices icon
221
222              The width and height arguments to tk::mac::iconBitmap define the
223              dimensions of the image to create, and -kind must be one of:
224
225              -file  icon of file at given path
226
227              -fileType
228                     icon of given file type
229
230              -osType
231                     icon of given 4-char OSType file type
232
233              -systemType
234                     icon for given IconServices 4-char OSType
235
236              -namedImage
237                     named NSImage for given name
238
239              -imageFile
240                     image at given path
241

SEE ALSO

243       bind(n), wm(n)
244

KEYWORDS

246       about dialog, antialiasing, Apple event, icon, NSImage
247
248
249
250Tk                                    8.6                           tk::mac(n)
Impressum