I have an outline view and want to get the contents (i.e. the text in the 1st column) of the row(s) that are selected by the user (preferably not in an “on cell value changed” handler, but in a custom hander of mine I call when a certain button is clicked).
I tried this:
set theObject to outline view "outline" of scroll view "scroll" of window "main"
set myRows to selected rows of theObject -- here I get the number(s) of the selected rows
set myEnd to count myRows
repeat with i from 1 to myEnd
log "Item " & i & ": " & title of selected row of theObject as string
end repeat
But this gets me this error message: Can’t make “class titl” of “class selR” of “class outV” id 3 of “class scrV” id 2 of window id 1 into type reference. (-1700)
What is wrong with this? Any hint is appreciated!
Ah, by the way: can anyone recommend a book on AppleScript Studio? All the AppleScript books only have a few pages on it and I keep struggling with the Studio…
Unfortunately the code doesn’t work in my app. I assume it is because I don’t use a data object - these are driving me nuts, I just don’t get it how to set them up. Maybe you could help me understand these?
Here is what I try:
I create a super simple interface with just an outline view named “outline” in a scroll view “scroll” in a window “main” which is connected to “will open”.
I set up a ASKDataSource in Interface Builder and connect the outline to it, clicking “Connect” in the “Connections” inspector.
Then I have this code:
on will open theObject -- event from window "main"
set theDataSource to the data source of outline view "outline" of scroll view "scroll" of window "main"
delete every data row of theDataSource
make new data column at end of data columns of theDataSource with properties {name:"Files"}
set theDataRow to make new data row at end of data rows of theDataSource
set contents of data cell "Files" of theDataRow to "myTest"
log contents of data cell "Files" of theDataRow as string -- this shows me "myTest" in the Log, but nothing in the outline
end will open
This doesn’t get me any errors, but the outline is still empty. What is my mistake? (I also tried setting up a new data source with AS and not doing so in Interface Builder, but also to no avail.)
It’s so easy once you know it, but I was completey struck. Thank you for helping with this.
I don’t want to seem too demanding: but do you have a hint on how to master Data Sources? I did the tutorial in the Apple Developer section, and can reproduce the results here. But any time I am trying to do something slightliy different, nothing happens…