This chapter describes the terminology in AppleScript Studio’s Container View suite.
The Container View suite defines the view
class, as well as additional classes whose primary purpose is to contain other views. Most of the classes in the Container View suite inherit from the responder
class, either directly or through the view
class, so they are able to respond to keystrokes and mouse actions. The Container View suite also defines events for working with container views and the views they contain.
The classes, commands, and events in the Container View suite are described in the following sections:
For enumerated constants, see “Enumerations.”
The Container View suite contains the following classes:
A simple view that can draw a border around itself and can title itself.
You can use a box to visually group other views or to serve as simple separators.
Figure 3-1 shows several boxes, including an empty box, a box that contains two radio buttons, and boxes used as horizontal and vertical separators. In Interface Builder, you will find separator boxes on the Cocoa Views palette (along with various buttons and text views), while container boxes are on the Container Views palette (along with tab and custom views).
See the scroll view
class for information on how to make objects into subviews of a box or other view in Interface Builder.
In addition to the properties it inherits from the view
class, a box
object has these properties:
border rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the bounds of the border; a four-item list of numbers, {left,
bottom, right, top} ; the box has its own coordinate system, so that the {left, bottom} value is always {0, 0}; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
border type | ||||
Access: | read/write | |||
Class: | enumerated constant from Border Type | |||
the border type | ||||
box type | ||||
Access: | read/write | |||
Class: | enumerated constant from Box Type | |||
the box type | ||||
content view | ||||
Access: | read/write | |||
Class: | view | |||
the content view of the box, which contains all of its subviews; for related information, see the content
view property of the window class | ||||
content view margins | ||||
Access: | read/write | |||
Class: | point | |||
the margins of the content view, offset from the border of the box; a two item list of numbers {left,
bottom} ; default is {5.0, 5.0}; in order to see any change from setting this property, you will have to use the call method command, as in the following example: | ||||
tell box 1 | ||||
set content view margins to {2.5,
2.5} | ||||
call method "sizeToFit" | ||||
end tell | ||||
title | ||||
Access: | read/write | |||
Class: | Unicode text | |||
the title of the box | ||||
title cell | ||||
Access: | read only | |||
Class: | cell | |||
the cell of the title | ||||
title font | ||||
Access: | read only | |||
Class: | font | |||
not supported (through AppleScript Studio version 1.4); the font for the cell title | ||||
title position | ||||
Access: | read/write | |||
Class: | enumerated constant from Title Position | |||
the position of the title | ||||
title rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the bounds of the title | ||||
the bounds of the border; a four-item list of numbers, {left,
bottom, right, top} ; offset within the coordinate system of the box; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class |
A box
object can contain only the elements it inherits from view
.
A box
object supports handlers that can respond to the following events:
conclude drop | ||||
drag | ||||
drag entered | ||||
drag exited | ||||
drag updated | ||||
drop | ||||
prepare drop |
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
bounds changed |
For a window “main” that contains a box with several text fields, you could set the text of one of the fields with the following statement:
set contents of text field "company" of box "info" of window "main" to "Acme Nuts and Bolts, Ltd." |
To access various properties of the same box, you could do the following:
tell window "main" |
tell box "info" |
set boxTitle to title |
set boxType to type |
-- and so on |
end tell |
end tell |
Support for drag-and-drop commands was added in AppleScript Studio version 1.2.
The title font
property in this class is not supported, through AppleScript Studio version 1.4.
A view that contains and scrolls the document view displayed by a scroll view.
You normally don't need to script a clip view, as the scroll view
class handles most of the details of scrolling when changes in the document view’s size or position require it. The scroll view
class also provides access to many of the same properties listed for the clip view
class.
In addition to the properties it inherits from the view
class, a clip
view
object has these properties:
background color | ||||
Access: | read/write | |||
Class: | RGB color | |||
the background color of the clip view; a three-item integer list that contains the values for each component of the color; for example, blue can be represented as {0,0,65535}; by default, {65535, 65535, 65535}, or white | ||||
content view | ||||
Access: | read/write | |||
Class: | view | |||
the content view of the clip view, which contains all of its subviews; for related information, see the content
view property of the window class | ||||
copies on scroll | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the contents of the view be copied when scrolled? | ||||
document rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the bounds of the document view in the clip view; a four-item list of numbers, {left, bottom, right, top} ; offset within the coordinate system of the clip view; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
document view | ||||
Access: | read/write | |||
Class: | view | |||
the main subview of the clip view; for example, a table view or text view | ||||
draws background | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the clip view draw its background? | ||||
visible document rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the visible bounds of the document view; a four-item list of numbers, {left, bottom, right, top} ; offset within the coordinate system of the clip view; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class |
A clip view
object can contain only the elements it inherits from view
.
This class is not accessible in Interface Builder, and you cannot connect any event handlers to it.
A user interface element that contains and displays view objects.
Drawers typically contain text field
, scroll view
, browser
, and other objects based on classes that inherit from the view
class. Figure 3-2 shows a drawer that contains many user interface objects.
A drawer is associated with a window
, called its parent, and can only appear while its parent is visible on screen. A drawer cannot be moved or ordered independently of a window, but is instead attached to one edge of its parent and moves along with it.
To add a drawer to your AppleScript Studio application, you drag it from the Cocoa-Windows palette, shown in Figure 3-3. You typically use the window item shown with an open drawer on the left. That’s a convenience object that takes care of the overhead of creating and connecting a window, its drawer, and the content view for the drawer. If you drag that window to your main nib window, you will see the three instances visible in the bottom row in Figure 3-4. You use them as follows:
NSDrawer instance: To connect event handlers for the drawer object, select the NSDrawer instance and open the Info window to the AppleScript pane.
ParentWindow instance: To add interface items to the window that owns the drawer, double-click the ParentWindow instance to open the window. You can also use the Info window to connect event handlers for the window.
DrawContentsView instance: To add interface items to the drawer, double-click the DrawContent… instance to open a window (shown in Figure 3-5). You can also use the Info window to connect event handlers for the window. You will see that the Info window identifies the instance as “NSView (Custom)”.
Once you have added a window and drawer in Interface Builder, you will have to take steps to show the window in your application, and to allow a user to open and close the drawer. You can show the window by connecting a launched
handler to the File’s Owner object (which represents the application) in the main nib window. See the application
class for more information about the File’s Owner.
If you give your drawer window the AppleScript name “main” (in the AppleScript pane in the Info window in Interface Builder), your launched
handler might look something like this one, from the Drawer sample application, available at <Xcode>/Examples/AppleScript Studio
:
on launched theObject |
show window "main" |
end launched |
To allow a user to open and close the drawer, you might add a button with the title “Open Drawer”. You could then connect a clicked
handler to the button that
opens or closes the drawer according to the current state of the drawer
sets the button title to reflect the state of the drawer (such as “Open Drawer” when the drawer is closed and “Close Drawer” when the drawer is open)
You can use the open drawer
command to open or close a drawer. For example, the following statement opens a drawer named “drawer”:
tell drawer "drawer" to open drawer |
It is also possible to instantiate a drawer by itself (without a parent window or content view) by dragging the object labeled “Drawer” in Interface Builder’s Cocoa-Windows palette to a nib window. In that case, you will get just the NSDrawer instance, and you will have to hook it up to a window and content view yourself (the details of which are beyond the scope of this reference).
For more information, see the document Drawers.
In addition to the properties it inherits from the responder
class, a drawer object has these properties:
content size | ||||
Access: | read/write | |||
Class: | point | |||
the size of the content view of the drawer; the size is returned as a two-item list of numbers {horizontal, vertical}; for example, {200, 100} would indicate a width of 200 and a height of 100; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
content view | ||||
Access: | read/write | |||
Class: | view | |||
the content view of the drawer (described above), which contains all of its subviews; for related information, see the content
view property of the window class | ||||
edge | ||||
Access: | read only | |||
Class: | enumerated constant from Rectangle Edge | |||
the edge of the window that the drawer is on | ||||
leading offset | ||||
Access: | read/write | |||
Class: | real | |||
for a drawer that opens on the left or right side, the distance from the top edge of the window to the top edge of the drawer | ||||
for a drawer that opens on the top or bottom side, the distance from the left edge of the window to the left edge of the drawer | ||||
if the leading offset is 0, the leading edge of the drawer is flush with the edge of the window; if you run the Drawer sample application (shown in Figure 3-2) you can adjust the leading offset to see how the drawer moves in relation to the window | ||||
maximum content size | ||||
Access: | read/write | |||
Class: | point | |||
the maximum size of the content view of the drawer; the size is returned as a two-item list of numbers {horizontal, vertical}, similar to the content size property above | ||||
minimum content size | ||||
Access: | read/write | |||
Class: | point | |||
the minimum size of the content of the drawer; the size is returned as a two-item list of numbers {horizontal, vertical}, similar to the maximum content size property above | ||||
parent window | ||||
Access: | read/write | |||
Class: | window | |||
the window that the drawer belongs to | ||||
preferred edge | ||||
Access: | read/write | |||
Class: | enumerated constant from Rectangle Edge | |||
the preferred edge (or side) on which to open the drawer; default is left edge ; you can set this property in the Info window in Interface Builder; note that the preferred edge may be ignored if there is not room to open the drawer in that direction | ||||
state | ||||
Access: | read/write | |||
Class: | enumerated constant from Drawer State | |||
the open/closed state of the drawer | ||||
trailing offset | ||||
Access: | read only | |||
Class: | real | |||
for a drawer that opens on the left or right side, the distance from the bottom edge of the window to the bottom edge of the drawer | ||||
for a drawer that opens on the top or bottom side, the distance from the right edge of the window to the right edge of the drawer | ||||
if the trailing offset is 0, the trailing edge of the drawer is flush with the edge of the window; if you run the Drawer sample application (shown in Figure 3-2) you can adjust the trailing offset to see how the drawer moves in relation to the window |
A drawer
object can contain the elements listed below. Your script can access most elements with any of the key forms described in “Standard Key Forms.”
box | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s boxes | ||||
browser | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s browsers | ||||
button | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s buttons | ||||
clip view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s clip views | ||||
color well | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s color wells | ||||
combo box | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s combo boxes | ||||
control | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s controls | ||||
image view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s image views | ||||
matrix | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s matrixes | ||||
movie view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s movie views | ||||
outline view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s outline views | ||||
popup button | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s popup buttons | ||||
progress indicator | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s progress indicators | ||||
scroll view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s scroll views | ||||
secure text field | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s secure text fields | ||||
slider | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s sliders | ||||
split view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s split views | ||||
stepper | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s steppers | ||||
tab view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s tab views | ||||
table header view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s table header views | ||||
table view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s table views | ||||
text field | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s text fields | ||||
text view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s text views | ||||
view | ||||
Specify by: | “Standard Key Forms” | |||
the drawer’s views |
Your script can send the following commands to a drawer
object:
close drawer | ||||
open drawer |
A drawer object supports handlers that can respond to the following events:
Drawerclosed | ||||
opened | ||||
should close | ||||
should open | ||||
will close | ||||
will open | ||||
will resize |
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
For an overview of working with drawers, see the description above for this class. For a detailed programming example of working with drawers, see the Drawer sample application, available at <Xcode>/Examples/AppleScript Studio
.
Provides the ability to scroll a document view that's too large to display in its entirety.
In addition to handling scrolling of the view, a scroll view can display horizontal and vertical scrollers and rulers (depending on how it is configured. Most scrolling is handled automatically by the scroll view, but see the scroll
command for a mechanism you can use to scroll in a text view.
A number of AppleScript Studio classes automatically include a scroll view, including the outline view
, table view
, and text view
classes. In Interface Builder, you can enclose any interface objects in a scroller by selecting the objects, choosing “Make subviews of” from the Layout menu, and then choosing Scroll View. You can use the same mechanism to make views be subviews of a box
, a split view
, or a tab view
.
You can also use this mechanism to group objects on a custom view (defined by you) or some other kind of built-in view (such as a matrix
). To do so, follow these steps:
Select the objects to be grouped.
Choose “Make subviews of” from the Layout menu and choose “Custom View”.
Select the resulting custom view. By default, it will be a view
object (of class NSView).
In the Custom Class pane of the Info window, select the desired class type.
For related information, see the document Cocoa Drawing Guide.
In addition to the properties it inherits from the view
class, a scroll
view
object has these properties:
background color | ||||
Access: | read/write | |||
Class: | RGB color | |||
the color of the background; a three-item integer list that contains the values for each component of the color; for example, blue can be represented as {0,0,65535}; default is {65535, 65535, 65535} (or white) | ||||
border type | ||||
Access: | read/write | |||
Class: | enumerated constant from Border Type | |||
the type of border for the scroll view | ||||
content size | ||||
Access: | read only | |||
Class: | point | |||
the size of the content view of the scroll view; the size is returned as a two-item list of numbers {horizontal, vertical}; for example, {200, 100} would indicate a width of 200 and a height of 100; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
content view | ||||
Access: | read/write | |||
Class: | view | |||
the content view; a clip view that clips the document view; for related information, see the content
view property of the window class | ||||
document view | ||||
Access: | read/write | |||
Class: | view | |||
the document view that the scroller scrolls; | ||||
draws background | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the scroll view draw the background? default is true ; | ||||
dynamically scrolls | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the view scroll dynamically? default is true ; | ||||
has horizontal ruler | ||||
Access: | read/write | |||
Class: | boolean | |||
Does the scroll view have a horizontal ruler? | ||||
has horizontal scroller | ||||
Access: | read/write | |||
Class: | boolean | |||
Does the scroll view have a horizontal scroller? | ||||
has vertical ruler | ||||
Access: | read/write | |||
Class: | boolean | |||
Does the scroll view have a vertical ruler? | ||||
has vertical scroller | ||||
Access: | read/write | |||
Class: | boolean | |||
Does the scroll view have a vertical scroller? | ||||
horizontal line scroll | ||||
Access: | read/write | |||
Class: | real | |||
the horizontal amount to line scroll | ||||
horizontal page scroll | ||||
Access: | read/write | |||
Class: | real | |||
the horizontal amount to page scroll | ||||
horizontal ruler view | ||||
Access: | read/write | |||
Class: | anything | |||
the horizontal ruler view | ||||
horizontal scroller | ||||
Access: | read/write | |||
Class: | anything | |||
the horizontal scroller | ||||
line scroll | ||||
Access: | read/write | |||
Class: | real | |||
the amount to line scroll | ||||
page scroll | ||||
Access: | read/write | |||
Class: | real | |||
the amount to page scroll | ||||
rulers visible | ||||
Access: | read/write | |||
Class: | boolean | |||
Are the rulers visible? | ||||
vertical line scroll | ||||
Access: | read/write | |||
Class: | real | |||
the vertical amount to line scroll | ||||
vertical page scroll | ||||
Access: | read/write | |||
Class: | real | |||
the vertical amount to page scroll | ||||
vertical ruler view | ||||
Access: | read/write | |||
Class: | anything | |||
the vertical ruler view | ||||
vertical scroller | ||||
Access: | read/write | |||
Class: | anything | |||
the vertical scroller | ||||
visible document rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the visible bounds of the document |
A scroll view
object can contain only the elements it inherits from view
.
A scroll view
object supports handlers that can respond to the following events:
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
bounds changed |
Because several kinds of objects, including outline, table, and text views automatically reside on a scroll view, AppleScript Studio applications often need to include a scroll view in specifying an object. The following line is from the Table sample application, available at <Xcode>/Examples/AppleScript Studio
.
tell table view "contacts" of scroll view "contacts" |
of window of theObject to update |
You can access properties of a scroll view with statements like the following, which sets a boolean variable based on whether the scroll view has a vertical scroller:
set hasVertScroller to has vertical scroller of scroll view "contacts" of window of theObject |
Support for drag-and-drop commands was added in AppleScript Studio version 1.2.
Stacks several subviews within one view to coordinate changes in their relative sizes.
The pane splitter bars between the views can be horizontal or vertical, depending on whether the views are arranged vertically or side by side. In Figure 3-6, an outline view appears above a table view.
See the scroll view
class for information on how to make objects into subviews of a split view or other view in Interface Builder.
In addition to the properties it inherits from the view
class, a split view object has these properties:
pane splitter | ||||
Access: | read/write | |||
Class: | boolean | |||
Is there a pane splitter? (see the horizontal bars in the middle of Figure 3-6) | ||||
vertical | ||||
Access: | read/write | |||
Class: | boolean | |||
Is the splitter vertical? |
A split view
object can contain only the elements it inherits from view
.
A split view object supports handlers that can respond to the following events:
Drag and Dropconclude drop | ||||
drag | ||||
drag entered | ||||
drag exited | ||||
drag updated | ||||
drop | ||||
prepare drop |
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
resized sub views | ||||
will resize sub views |
bounds changed |
The following script gets the vertical
property of a split view in the Mail Search sample application, available at <Xcode>/Examples/AppleScript Studio
. This script is not part of the application, but you can run it from Script Editor to access the property in the Mail Search application. Similar statements will work within an AppleScript Studio application script (though you won’t need the tell application
statement).
tell application "Mail Search" |
tell front window |
set isVertical to vertical of first split view |
-- Do something based on result |
end tell |
end tell |
You may also need to refer to a split view to access another view in your application. The following fragment from Mail Search specifies a scroll view on a split view of a window:
tell scroll view "mailboxes" of split view 1 of theWindow |
-- Access properties or subviews of the scroll view. |
end tell |
Support for drag-and-drop commands was added in AppleScript Studio version 1.2.
Prior to AppleScript Studio version 1.1, the Mail Search sample application was named Watson.
Provides a convenient way to present information in multiple pages.
The view contains a row of tabs that select different panes, as shown in Figure 3-7. The user selects the desired page by clicking the appropriate tab or using the arrow keys to move between pages. Each page displays a view hierarchy provided by your application. Each tab, and its associated view hierarchy, is represented by a tab view item
.
The Examples section describes how to use a tab view to give the appearance of switching out the entire contents of a view.
Important: You cannot access user interface elements of a tab view item unless it is the current tab view item. A tab view switches tabs by removing the view for one tab view item and adding the view for another to the view hierarchy. AppleScript must walk the view hierarchy to get access to the user interface elements in its subviews.
Your application that uses a tab view can perform any necessary validation on the user interface elements on a tab view item before the item is switched out. You can do this in the should select tab view item
event handler, which is called when the tab view is about to switch tab view items. If the tab view item is valid, you should save any required information from its user interface elements and allow it to be switched out. Your application can do any necessary work to prepare the user interface elements on a tab view item when it is switched in. You can do this in the selected tab view item
event handler, which is called when the current tab view item has been changed. The Assistant sample application, available at <Xcode>/Examples/AppleScript Studio
, shows one way to perform these operations.
See the scroll view
class for information on how to make objects into subviews of a tab view or other view in Interface Builder.
In addition to the properties it inherits from the view
class, a tab
view
object has these properties:
content rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the bounds for contents of the tab view; a four-item list of numbers, {left, bottom, right, top} ; the bounding rectangle is offset within the tab view’s coordinate system; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
control size | ||||
Access: | read/write | |||
Class: | enumerated constant from Control Size | |||
the size of the tabs; default is regular
size ; you can set this property in Interface Builder (with the Small Tabs checkbox in the Attributes pane of the Info window) | ||||
control tint | ||||
Access: | read/write | |||
Class: | enumerated constant from Control Tint | |||
the tint of the tabs; default is default
tint | ||||
current tab view item | ||||
Access: | read/write | |||
Class: | tab view item | |||
the current tab view item | ||||
draws background | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the tab view draw its background? default is true ; see the description above for information on when you can set this property in the Info window in Interface Builder | ||||
tab type | ||||
Access: | read/write | |||
Class: | enumerated constant from Tab View Type | |||
the type of tab (such as a bezeled tab on the top of the tab view); you can set tab direction (Top, Left, Bottom, or Right) in Interface Builder, though Left, Bottom, and Right work only with the version of Cocoa that became available with Mac OS X version 10.2. | ||||
truncated labels | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the labels be truncated, if necessary? you can set this property in the Info window in Interface Builder |
In addition to the elements it inherits from the view
class, a tab
view
object can contain the elements listed below. Your script can access most elements with any of the key forms described in “Standard Key Forms.”
tab view item | ||||
Specify by: | “Standard Key Forms” | |||
the view’s tab view items, one per tab in the view |
A tab view object supports handlers that can respond to the following events.
Drag and Dropconclude drop | ||||
drag | ||||
drag entered | ||||
drag exited | ||||
drag updated | ||||
drop | ||||
prepare drop |
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
selected tab view item | ||||
update parameters | ||||
will select tab view item |
bounds changed |
Given appropriately-named objects, you can use terminology like the following to set the text in a text field on a tab view:
set contents of text field "textFieldName" of view of tab view item "tabViewItemName" of tab view "tabViewName" of window "windowname" |
Items on a tab view item are actually on a view that’s on the tab view item, which accounts for the view
in the phrase of view of tab view item
in this example. However, starting in AppleScript Studio version 1.2, you no longer need to specify the view, and can use the following, slightly simpler form:
set contents of text field "textFieldName" of tab view item "tabViewItemName" of tab view "tabViewName" of window "windowname"' |
You can use a tab view to give the appearance of switching out the entire contents of a view. In Interface Builder, drag a tab view from the Cocoa-Containers pane of the Palette window to the target window. With the tab view selected, select the Tabless radio button. You can then choose styles between having a drop shadow or having no visible frame at all. If you choose no visible frame, you can also choose whether the tab view should draw its background.
You will still be able to put whatever user interface items you want on each tab view item. Because there are no tabs to select, the Info window provides a stepper control to navigate between tab view items. Since a user won’t be able to select among tabs (presumably that’s your goal), you will have to change the currently displayed tab view item programmatically, with statements like the following (if you’ve given the first tab view item the name "tabViewItem1"
):
tell tab view "tabview" of window "main" |
set the current tab view item to tab view item "tabViewItem1" |
end |
The Assistant sample application, available at <Xcode>/Examples/AppleScript Studio
, shows how to use a tab view and separate tab view items to represent an information panel.
Support for drag-and-drop commands was added in AppleScript Studio version 1.2.
Tab views in AppleScript Studio are implemented by Cocoa’s NSTabView
class. Prior to Mac OS X version 10.2, NSTabView only supported tab views with the tabs on the top.
Starting with AppleScript Studio version 1.2, a script can say button 1 of tab view item 1 of tab view
1
instead of button 1
of view of tab view item 1 of tab view 1
, though the longer version still works (and will run with any version of AppleScript Studio, not just version 1.2). See the Examples section above for another example.
Represents one tab in a tab view.
When a user clicks on a tab, the tab view
displays a view page provided by your application. A tab view keeps a one-based array of tab view items, one for each tab in the view. The tab view in Figure 3-7 has four tab view items.
When you drag a tab view from the Cocoa-Containers pane of Interface Builder’s Palette window, it contains two tab view items. You can set the number of tab view items in Interface Builder’s Info window.
A tab view item has these properties:
color | ||||
Access: | read/write | |||
Class: | RGB color | |||
the RGB color of the tab view item; a three-item integer list that contains the values for each component of the color; for example, blue can be represented as {0,0,65535}; default is {65535, 65535, 65535} (or white) | ||||
label | ||||
Access: | read/write | |||
Class: | Unicode text | |||
the label of the tab view item; you can set the label in Interface Builder | ||||
tab state | ||||
Access: | read only | |||
Class: | enumerated constant from Tab State | |||
the state of the tab view item | ||||
tab view | ||||
Access: | read only | |||
Class: | tab view | |||
the tab view that contains this tab view item | ||||
view | ||||
Access: | read/write | |||
Class: | view | |||
the view of the tab view item (on which you place the user-interface objects for the tab view item) |
A tab view item supports handlers that can respond to the following events:
Nibawake from nib |
The following handler is from the sample application Assistant, available at <Xcode>/Examples/AppleScript Studio
(starting with AppleScript Studio version 1.1). This handler is called when the script’s properties need to be updated from the contents of user interface objects associated with a tab view item. As the first line of the tell
statement shows, the terminology to access a tab view can be quite complex. A common error prior to AppleScript Studio version 1.2 was to omit view
of
at the beginning of the statement. Starting with version 1.2, the view of
is optional.
Within the tell
block, the statements to gather information from individual text field objects are more straightforward. Each statement assigns a value to a property of the script.
on updateValues(theWindow) |
tell view of tab view item infoPanelName of tab view "info panels" |
of box "border" of theWindow |
set my company to contents of text field "company" |
set my name to contents of text field "name" |
set my address to contents of text field "address" |
set my city to contents of text field "city" |
set my state to contents of text field "state" |
set my zip to contents of text field "zip" |
set my email to contents of text field "email" |
end tell |
end updateValues |
The Examples section for the tab view
class describes how to use a tab view to give the appearance of switching out the entire contents of a view by switching tab view items.
An abstract class that defines the basic drawing, event-handling, and printing architecture of an application.
Your scripts typically don't interact with view
objects directly; rather, they interact with the many user interface classes that inherit from the view
class.
You can create and access a view
object in Interface Builder with the following step:
Drag a CustomView instance from the Cocoa-Containers pane of the Palette window to the target window. This view is by default a view
object of class NSView.
To change the class to a custom view class you have defined, or to another built-in class type, use these steps:
Select the custom view.
In the Custom Class pane of the Info window, select the new class type.
In addition to the properties it inherits from the responder
class, a view
object has these properties:
auto resizes | ||||
Access: | read/write | |||
Class: | boolean | |||
Should the view auto resize? | ||||
bounds | ||||
Access: | read/write | |||
Class: | bounding rectangle | |||
the position and size of the view (within its superview); the bounds are returned as a four-item list of numbers {left,
bottom, right, top} ; the bounding rectangle is offset from {0, 0} in the superview; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
bounds rotation | ||||
Access: | read/write | |||
Class: | real | |||
the rotation of the bounds rectangle, in degrees; default is 0.0; positive values indicate counterclockwise rotation, negative clockwise; rotation is performed around the coordinate system origin, (0.0, 0.0), which need not coincide with that of the frame rectangle or the bounds rectangle; changing this value does not redisplay the view or mark it as needing display; you can do that by setting the needs display property to true , or by using the update command | ||||
can draw | ||||
Access: | read only | |||
Class: | boolean | |||
Can the view be drawn? true if drawing commands will produce any result, false otherwise; this property is used when invoking drawing directly, along with the lock focus and unlock focus commands; however, those commands are not supported through AppleScript Studio version 1.4; in addition, AppleScript Studio doesn’t currently provide fine control over drawing, and most applications will not need to invoke drawing directly; if your application is an exception, see NSView , as well as the documents pointed to in the documentation for that class | ||||
enclosing scroll view | ||||
Access: | read/write | |||
Class: | scroll view | |||
the scroll view of the view (if any); see the description of the scroll view class for how to enclose a view in a scroll view in Interface Builder | ||||
flipped | ||||
Access: | read only | |||
Class: | boolean | |||
Is the coordinate system of the view flipped? by default the origin of a view’s coordinate system is in the lower left; however, for some views, the default for this property is true , meaning the origin is in the top left; this is a read-only property, and it’s unlikely your application will be concerned with it; see the bounds property of the window class for more information on the coordinate system, which is different than that used by the Mac OS Finder application; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
needs display | ||||
Access: | read/write | |||
Class: | boolean | |||
Does the view need to be displayed? setting this property to true will cause the view to be redrawn at the next opportunity; to cause an immediate redraw, use the update command; note that through AppleScript Studio version 1.4, the needs display property is not supported for the window class, but is supported for the view class | ||||
opaque | ||||
Access: | read only | |||
Class: | boolean | |||
Is the view opaque? see the description for the opaque property in the window class | ||||
position | ||||
Access: | read/write | |||
Class: | point | |||
position of the view within its superview as a two-item list of numbers {left, bottom} ; each view has its own coordinate system, with the origin in the lower left corner; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
size | ||||
Access: | read/write | |||
Class: | point | |||
the size of the view; the size is returned as a two-item list of numbers {horizontal, vertical}; for example, {200,
100} would indicate a width of 200 and a height of 100; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
super view | ||||
Access: | read/write | |||
Class: | view | |||
the view that contains this view | ||||
tag | ||||
Access: | read/write | |||
Class: | integer | |||
the tag for the view; you can set the tag for some views, such as text field views, in the Info window in Interface Builder | ||||
tool tip | ||||
Access: | read/write | |||
Class: | Unicode text | |||
the tooltip text for the view (text to be displayed if the user lets the cursor hover over the view) | ||||
visible | ||||
Access: | read/write | |||
Class: | boolean | |||
Is the view visible? | ||||
visible rect | ||||
Access: | read only | |||
Class: | bounding rectangle | |||
the visible area of the view; a four-item list of numbers, {left,
bottom, right, top} ; the view has its own coordinate system; see the bounds property of the window class for more information on the coordinate system; for changes introduced in AppleScript Studio version 1.4, see the main discussion for the application class, as well as the coordinate system property of that class | ||||
window | ||||
Access: | read/write | |||
Class: | window | |||
the window that contains this view |
A view
object can contain the elements listed below. Your script can access most elements with any of the key forms described in “Standard Key Forms.”
box | ||||
Specify by: | “Standard Key Forms” | |||
the view’s boxes | ||||
browser | ||||
Specify by: | “Standard Key Forms” | |||
the view’s browsers | ||||
button | ||||
Specify by: | “Standard Key Forms” | |||
the view’s buttons | ||||
clip view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s clip views | ||||
color well | ||||
Specify by: | “Standard Key Forms” | |||
the view’s color wells | ||||
combo box | ||||
Specify by: | “Standard Key Forms” | |||
the view’s combo boxes | ||||
control | ||||
Specify by: | “Standard Key Forms” | |||
the view’s controls | ||||
image view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s image views | ||||
matrix | ||||
Specify by: | “Standard Key Forms” | |||
the view’s matrixes | ||||
movie view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s movie views | ||||
outline view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s outline views | ||||
popup button | ||||
Specify by: | “Standard Key Forms” | |||
the view’s popup buttons | ||||
progress indicator | ||||
Specify by: | “Standard Key Forms” | |||
the view’s progress indicators | ||||
scroll view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s scroll views | ||||
secure text field | ||||
Specify by: | “Standard Key Forms” | |||
the view’s secure text fields | ||||
slider | ||||
Specify by: | “Standard Key Forms” | |||
the view’s sliders | ||||
split view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s split views | ||||
stepper | ||||
Specify by: | “Standard Key Forms” | |||
the view’s steppers | ||||
tab view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s tab views | ||||
table header view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s table header views | ||||
table view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s table views | ||||
text field | ||||
Specify by: | “Standard Key Forms” | |||
the view’s text fields | ||||
text view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s text views | ||||
view | ||||
Specify by: | “Standard Key Forms” | |||
the view’s views |
Your script can send the following commands to a view
object:
lock focus (not supported through AppleScript Studio version 1.4) | ||||
register | ||||
unlock focus (not supported through AppleScript Studio version 1.4) |
A view
object view supports handlers that can respond to the following events. To connect an event handler to a view
object in Interface builder, put the nib window for the window
object that contains the view into outline mode by clicking the small outline icon above the right scroll bar; use the disclosure triangles to open the window
and other enclosed objects until the view
object is visible; select it, then connect the event handler in the AppleScript pane of the Info window.
conclude drop | ||||
drag | ||||
drag entered | ||||
drag exited | ||||
drag updated | ||||
drop | ||||
prepare drop |
keyboard down | ||||
keyboard up |
mouse down | ||||
mouse dragged | ||||
mouse entered | ||||
mouse exited | ||||
mouse up | ||||
right mouse down | ||||
right mouse dragged | ||||
right mouse up | ||||
scroll wheel |
awake from nib |
bounds changed |
The view
class is an abstract class that you don’t typically target in your scripts. More often you target subclasses, such as box
or scroll view
or tab view
. The control
class also inherits from the view
class, so all subclasses of control inherit view properties and elements (though view elements such as a movie view or progress indicator are not of much use to a control such as a button).
You can use the following script in Script Editor to rotates the text in a text view
by 50 degrees. Similar statements will work within an AppleScript Studio application script (though you won’t need the tell application
statement).
tell application "rotate" |
tell window 1 |
tell scroll view 1 |
tell text view 1 |
set bounds rotation to 50.0 |
set needs display to true |
end tell |
end tell |
end tell |
end tell |
Through AppleScript Studio version 1.4, the needs
display
property is not supported for the window
class, but is supported for the view
class.
The lock focus
and unlock focus
commands are not supported through AppleScript Studio version 1.4.
Objects based on classes in the Container View suite support the following commands. (A command is a word or phrase a script can use to request an action.) To determine which classes support which commands, see the individual class descriptions.
Closes the specified drawer.
close drawer |
reference | required |
a reference to the drawer
to close
For a window with AppleScript name “main” that contains a drawer named “drawer” you can close the drawer with a tell
statement like the following:
tell window "main" |
tell drawer "drawer" to close |
end tell |
Not supported (through AppleScript Studio version 1.4). Locks the focus on a view to prepare it for drawing.
lock focus |
reference | required |
a reference to the view object for which to lock focus
Opens the specified drawer.
open drawer |
reference | required | |
on |
enumerated constant | optional |
a reference to the drawer
to open
on
enumerated constant from Rectangle Edgethe edge of the window to open the drawer on
For a window with AppleScript name “main” that contains a drawer named “drawer” you can open the drawer on the left side of the window with a tell
statement like the following:
tell window "main" |
tell drawer "drawer" to open drawer on left edge |
end tell |
Not supported (through AppleScript Studio version 1.4). Unlocks the focus on a view after drawing is complete.
unlock focus |
reference | required |
a reference to the view object for which to unlock focus
Objects based on classes in the Container View suite support handlers for the following events (an event is an action, typically generated through interaction with an application’s user interface, that causes a handler for the appropriate object to be executed). To determine which classes support which events, see the individual class descriptions.
Called after a view
object’s bounds are changed.
bounds changed |
reference | required |
a reference to the view
whose bounds changed
When you connect a bounds changed
handler to a view
object in Interface Builder, AppleScript Studio supplies an empty handler template like the following. You can use the handler to react to a change in bounds. To determine the change in bounds, you will have to store the old bounds of the view and compare it to the current bounds.
on bounds changed theObject |
(* Perform operations here after bounds changed. *) |
end bounds changed |
Called after a view object’s subviews are resized.
resized sub views |
reference | required |
a reference to the object whose subviews were resized
When you connect a resized sub views
handler to a view
object in Interface Builder, AppleScript Studio supplies an empty handler template like the following. To determine the change in the view’s size, you will have to save the old size of the view (which you might do in a will resize sub views
handler) and compare it to the current size. You can use the handler to perform any operations necessary after subviews are resized.
on resized sub views theObject |
(* Perform operations here after sub views resized. *) |
end resized sub views |
Attached to an Automator action view and called after Automator calls the update parameters
handler.
For additional information, see Implementing an AppleScript Action in Introduction to Automator Programming Guide.
parameters updated |
reference | required | |
parameters |
record | required |
reference
the view for which the Automator action is run
parameters
recorda record containing values reflecting the settings users have made in the action’s user interface (after they were updated)
For additional information, see update parameters
and Introduction to Automator Programming Guide. In addition, see the sample Automator action templates in <Xcode>/Examples/Automator
.
The parameters updated
handler was added in AppleScript Studio version 1.4.
Called after a tab view item is selected, indicating the current tab view item has changed.
A tab view item represents one tab on a tab view
.
selected tab view item |
tab view | required | |
tab view item |
tab view item | optional |
tab viewthe tab view whose tab view item was selected
tab view item
tab view itemthe tab view item that was selected
The following selected tab view item
handler is from the Assistant sample application, available at <Xcode>/Examples/AppleScript Studio
(starting with AppleScript Studio version 1.1). This handler is called when the current tab view item has been changed. That’s a good place to perform any preparation before showing the contents of the tab.
on selected tab view item theObject tab view item tabViewItem |
-- We will give the new info panel a chance to |
-- prepare it's data values |
prepareValues(window of theObject) |
of infoPanelWithName(name of tabViewItem) |
end selected tab view item |
Called to determine whether the object’s tab view item should be selected, most likely because a user has clicked the associated tab.
The handler can return false
to refuse to allow the item to be selected (so there will be no switch of tab items) or true
to allow selection. A tab view item represents one tab on a tab view
.
should select tab view item |
tab view | required | |
tab view item |
tab view item | optional |
the tab view whose tab view item may be selected
tab view item
tab view itemthe tab view item
Return true
to allow selection; false
to disallow it. If you implement this handler, you should always return a boolean value.
The following example of a should select
tab view item
handler calls an application handler shouldSelectTabViewItem
, written by you, to determine whether to allow the item to be selected, then returns the appropriate value. You might instead perform validation in the handler itself or check some global property.
on should select tab view item theObject |
--Check property, perform test, or call handler to see if OK |
-- to select tab view item specified by theObject |
set allowSelection to shouldSelectTabViewItem(theObject) |
return allowSelection |
end should select tab view item |
The Assistant sample application, available starting with AppleScript Studio version 1.2, includes a should
select tab view item
handler that examines each panel before making a decision on whether to allow a change in the selected tab.
Attached to an Automator action view and called just before Automator runs the action.
For additional information, see Implementing an AppleScript Action in Introduction to Automator Programming Guide.
update parameters |
reference | required | |
parameters |
record | required |
reference
the view for which the Automator action is run
parameters
recorda record containing values reflecting the settings users have made in the action’s user interface
Return the (possibly updated) record that was passed to the handler.
For additional information, see parameters updated
and Introduction to Automator Programming Guide. In addition, see the sample Automator action templates in <Xcode>/Examples/Automator
.
The update parameters
handler was added in AppleScript Studio version 1.4.
Called when a view object’s subviews are about to be resized.
The handler cannot cancel the resizing, but can prepare for it.
will resize sub views |
reference | required |
a reference to the object whose subviews are about to be resized
When you connect a will resize sub views
handler to a view
object in Interface Builder, AppleScript Studio supplies an empty handler template like the following. You can use the handler to prepare for subviews being resized. For example, you might save the current size of the subviews
on will resize sub views theObject |
(* Perform any operations to prepare for resizing of subviews. *) |
end will resize sub views |
Called when a tab view item is about to be selected.
A tab view item represents one tab on a tab view
. The handler cannot cancel the selection, but can prepare for it.
will select tab view item |
tab view | required | |
tab view item |
tab view item | optional |
tab viewthe tab view whose tab view item is about to be selected
tab view item
tab view itemthe tab view item that is about to be selected
When you connect a will select tab view
item
handler to a tab
view
object in Interface Builder, AppleScript Studio supplies an empty handler template like the following. You can use the handler to prepare for the tab view item being selected.
on will select tab view item theObject |
(* Perform any operations to prepare for selection of the item. *) |
end will select tab view item |
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)