- ::tk::mac::DoScriptFile
-
The default Apple Event handler for AEDoScriptHandler. This command
executes a Tcl file when an AppleScript sends a
“do script”
command to Wish with a file path as a parameter.
- ::tk::mac::DoScriptText
-
The default Apple Event handler for AEDoScriptHandler. This command
executes Tcl code when an AppleScript sends a
“do script”
command to Wish with Tcl code or a Tcl procedure as a parameter.
- ::tk::mac::ShowPreferences
-
The default Apple Event handler for kAEShowPreferences,
“pref”.
The application menu
“Preferences”
menu item is only enabled when this proc is defined. Typically this command is
used to wrap a specific own preferences command, which pops up a preferences
window. Something like:
proc ::tk::mac::ShowPreferences {} {
setPref
}
- ::tk::mac::OpenApplication
-
If a proc of this name is defined, this proc fill fire when your application
is initially opened. It is the default Apple Event handler for
kAEOpenApplication,
“oapp”.
- ::tk::mac::ReopenApplication
-
If a proc of this name is defined it is the default Apple Event handler for
kAEReopenApplication,
“rapp”,
the Apple Event sent when your application is opened when it is already
running (e.g. by clicking its icon in the Dock). Here is a sample that raises
a minimized window when the Dock icon is clicked:
proc ::tk::mac::ReopenApplication {} {
if {[wm state .] eq "withdrawn"} {
wm state . normal
} else {
wm deiconify .
}
raise .
}
- ::tk::mac::OpenDocument file...
-
If a proc of this name is defined it is the default Apple Event handler for
kAEOpenDocuments,
“odoc”,
the Apple Event sent when your application is asked to open one or more
documents (e.g., by drag & drop onto the app or by opening a document of a
type associated to the app). The proc should take as arguments paths to the
files to be opened, like so:
proc ::tk::mac::OpenDocument {args} {
foreach f $args {my_open_document $f}
}
- ::tk::mac::PrintDocument file...
-
If a proc of this name is defined it is the default Apple Event handler for
kAEPrintDocuments,
“pdoc”,
the Apple Event sent when your application is asked to print a
document. It takes a single absolute file path as an argument.
- ::tk::mac::Quit
-
If a proc of this name is defined it is the default Apple Event handler for
kAEQuitApplication,
“quit”,
the Apple Event sent when your application is asked to be quit, e.g. via the
quit menu item in the application menu, the quit menu item in the Dock menu,
or during a logout/restart/shutdown etc. If this is not defined, exit is
called instead.
- ::tk::mac::OnHide
-
If defined, this is called when your application receives a kEventAppHidden
event, e.g. via the hide menu item in the application or Dock menus.
- ::tk::mac::OnShow
-
If defined, this is called when your application receives a kEventAppShown
event, e.g. via the show all menu item in the application menu, or by clicking
the Dock icon of a hidden application.
- ::tk::mac::ShowHelp
-
Customizes behavior of Apple Help menu; if this procedure is not defined, the
platform-specific standard Help menu item
“YourApp Help”
performs the default Cocoa action of showing the Help Book configured in the
application's Info.plist (or displaying an alert if no Help Book is
set).
- ::tk::mac::PerformService
-
Executes a Tcl procedure called from the macOS
“Services”
menu in the Application menu item. The
“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:
proc ::tk::mac::PerformService {} {
set data [clipboard get]
$w insert end $data
}
Note that the mechanism for retrieving the data is from the clipboard;
there is no other supported way to obtain the data. If the Services
process is not desired, the NSServices keys can be deleted from
the application's Info.plist file. The underlying code supporting this
command also allows the text, entry and ttk::entry widgets to access
services from other applications via the Services menu. The NSPortName
key in Wish's Info.plist file is currently set as
“Wish”
; if a developer changes the name of the Wish executable to something
else, this key should be modified with the same name.
- ::tk::mac::LaunchURL URL...
-
If defined, launches a URL within Tk. This would be used if a Tk
application wants to handle a URL itself, such as displaying data from
an RSS feed, rather than launching a default application to handle the
URL, although it can defined as such. Wish includes a stub URL scheme
of
“foo://”
in the CFBundleURLSchemes key of its Info.plist file; this should be customized for the specific URL
scheme the developer wants to support.
- ::tk::mac::GetAppPath
-
Returns the current applications's file path.
-
Copyright © 2011 Kevin Walzer.
Copyright © 2011 Donal K. Fellows.