The biggest area of change in terms of scripting is in access to window tabs, which is covered in detail below. But there are also several other scripting changes.
The application object has several new properties, and loses some others. With the introduction of Color Themes, the apply handler formatting
, handler color
, and script background color
properties been removed. The AppleScript format
class is also no longer relevant, so it is no longer an element of the application.
Script Debugger now supports searching, via the search
command, with relevant application properties search uses regex
, search matches words
, search ignores case
and search wraps
. You also set the search and replace string via application properties: search string
and search replace string
.
The open in tabs
property has been deprecated, in favor of the prefer tabs
property, which lets you choose whether to follow the system setting or override it.
Other new application properties are can notarize
, which tells you if the host Mac meets the requirements for notarizing apps, and several properties that cover settings in the Preferences -> Building pane: include notes on export
, which reflects the setting for the SD Script Notes.rtfd file; include source on export
, which controls whether a copy of the source should also be exported; export destination
, export destination fixed
and export folder name
, for controlling where exported files end up; lock applets
, which controls whether applets are locked; and version control friendly
, for scripts saved as script bundles.
You can get a list of available themes through the available themes
property, and get or set the active theme via the current theme
property. The application no longer has an AppleScript formats
collection.
The document
class has some new properties: autoincrement build number on export
joins autoincrement build number
; embed run only
and embed used frameworks
join embed used libraries
for exports; export name
gets and sets the name used used for exported files; codesign bundles too
controls whether the signing settings for applets should also apply to bundles (.scptd files); and show code folding
controls whether code folding is displayed in all the document’s windows.
There is a new command, direct export
, which provides access to the new Export Run-Only facility. You pass the document as the direct parameter, and the script type for the as
parameter.
Windows and Tabs
Script Debugger 8 is using system-provided tabbing for script windows, and as part of that change scripting support has been enhanced to include access to script window tabs. It has also resulted in a couple of less obvious changes.
To understand the way it works, it helps to have some understanding of how Apple implements tabs. Normal windows are easy to understand: window 1 is the frontmost window, and if you click on another window, it comes to the font to become the new window 1. Window indexes represent where windows appear in front-to-back layering order.
In a tabbed window, each tab actually represents a separate window, layered from the left tab to the right, with only the active tab’s window visible. When you click on a different tab to make it active, the order of the windows doesn’t change — all that changes is which one is visible.
Windows are represented in the AppleScript dictionary as script windows
, and each script window
contains one or more script window tabs
. The script window tab
class is a subclass of script window
: the active script window tab
is also a kind of script window
.
So if you ask for script window tab 1 of script window 1, the result will always be the left-most tab of the front script window, regardless of which tab is active. If a window has no tabs, script window tab 1 of script window 1 will be the same thing as script window 1.
To move a script window forwards or backwards, you can change its index
property. To move a script window tab within the tabbed group — say, to move it from left-most to right-most — you change the script window tab’s tab index
property.
To move scripts between tab groups, or to make tab groups, you can use the parent window
property. For example, if you have two windows open and you want to combine them into a single tabbed window, you could use set parent window of script window 1 to script window 2. To remove a tab from a group and make it a standalone window, set its tabbed
property to false: set tabbed of script window tab 2 of script window 1 to false
Script windows and script window tabs have some new properties. As mentioned above, only one tab in each tabbed window is drawn at any time. But as far as the system is concerned, they are still visible until they are closed, which means the visible
property is not very helpful. So script windows and script window tabs now have a content visible
property, which returns true only if they are the active tab. Similarly, the current document
property returns the document of the active tab.
One of the subtle changes in tab behavior compared with previous versions of Script Debugger involves window bounds. Suppose you have two windows, and you tab one into the other, and you then resize the resulting window. When you get the bounds of the hidden script window tab, it will still be its original size. In previous versions, you would also see it at this size if you then dragged the tab back out into a window of its own.
However Apple’s tabbing works a bit differently. Although the hidden window will still return its original bounds, as soon as it gets drawn — which is required when it’s dragged or otherwise made active — it is immediately resized to the size of the visible tab.
To deal with this, script windows and script window tabs have a parent bounds
property, which returns the bounds of the script window they belong to. And because of the way tabs work, you can probably think of it as the actual bounds, because that’s what it will be if such a tab ever gets made visible.
Script windows also have a tabbed
property, which will tell you if it is a tabbed window.
Whether new windows are tabbed is controlled by the prefer tabs
property, which has three options: yes
, no
and default
. These match the settings in Script Debugger’s preferences, with default
meaning to use the system-wide preference from System Preferences. The prefer tabs
property replaces the open in tabs
property, which has been renamed open tabs deprecated
. You can still use the old property, but because it is a boolean value, it cannot map to all three choices.
Similarly, the open
and make
commands have a new prefer tab
property, with the same three choices.