I have a window that contains a tab view with 4 tabs. In tab 1, I have a text view/scroll view. When I click a button outside the tab view, I want to retrieve any text in the text view that has been entered. So I tried the following:
on clicked theObject
tell window of theObject
set thisText to the contents of text view "myText" of scroll view "myText" of tab view item "tab1" of tab view "myTabsBox"
display dialog thisText
end tell
end clicked
This comes almost straight from the AppleScript Studio Terminology Reference. This does not work. However, if I replace the text view/scroll view with a text field, the following code works.
on clicked theObject
tell window of theObject
set thisText to the contents of text field "myText" of tab view item "tab1" of tab view "myTabsBox"
display dialog thisText
end tell
end clicked
So I don’t think I’m too far off. I need the scrolling text view because I want to write paragraphs in the view. Any help?
OK, I figured it out, if any ever runs into this problem.
As it turns out, the scroll view requires a name for the scroll view and the text view in the name field of the AppleScript section of the Info dialog box. Obviously, single-clicking on the scroll view will allow one to enter a name in the appropriate name field. Then, the scroll view must be double-clicked to select the text view. Once this view is selected, it must be named too. It’s ok if the scroll view and text view are given the same name.
You don’t need to name every scroll view and text view, you can just use the index:
or, for simplicity’s sake if you do have more than one text view/scroll view in a window/view, you can just name the scroll view since it is the sole direct parent of the text view: