Selecting an item from an outline view.

I am working on a document list displayed as an outline view. I have the outline view and everything working, but I am running out of ideas on how to select an item from the outline.

To populate the outline which is outline view “docOutline” of scroll view “docScroll” of window “Documents”, I use this:


on awake from nib theObject
	if theObject's name is "docOutline" then
		set theDocumentTree to {{docid:0, pageTitle:"http://localhost/", |items|:¬
			{{docid:2, pageTitle:"Blog", |items|:¬
				{{docid:3, pageTitle:"my story"}, {docid:60, pageTitle:"A blog entry"}, {docid:62, pageTitle:"Another blog entry"}, {docid:65, pageTitle:"Retardo entry"}}}, ¬
				{docid:74, pageTitle:"Members", |items|:¬
					{{docid:89, pageTitle:"WebSense"}, {docid:90, pageTitle:"Logout"}, {docid:91, pageTitle:"Account"}}}, ¬
				{docid:77, pageTitle:"Contact Page"}}}}
		set theOutline to outline view "docOutline" of scroll view "docScroll" of window "Documents"
		set content of theOutline to theDocumentTree
	end if
end awake from nib

Now I know it would be easier to just write “set the content of theObject to” instead of set “theDocument tre to”, but I want to make sure my paths are correct, so it is eventually going to be written the easy way.

I also set up a on double clicked handler, but I have no Idea how to select the outline item. I even set up a “should select item” handler and set it to log outlineItem which logs:
[log]
data item id 7 of data item id 6 of data item id 5 of data source id 4
[/log]
when I click “my story” which is a sub item of “Blog”. When I write:


set myStory to data item id 7 of data item id 6 of data item id 5 of data source id 4
display dialog myStory

I get a “NSReceiverEvaluationScriptError: 4 (1)” error.

I am really confused on how to select this. Basically, what I want to do is, when an item is double clicked, a new window will open with content based on the number associated with docid:, so I really just need to get the docid of the double clicked item.

I also read 4 or 5 pages of posts returned from a “Outline View” search on these forums, and it seems that Apples documentation AND support for outline views in AS Studio is limited.

Is this possible with AS Studio?

-sD-

Hi Scotty,

I think it is possible - try this:

on double clicked theObject
	display dialog "you clicked docid: " & (call method "objectForKey:" of (contents of clicked data item of theObject) with parameter "docid")
end double clicked

I have no idea why the applescript access to the record does not work - at least it didn’t for me:

...
display dialog "you clicked docid: " & (docid of (contents of clicked data item of theObject)) -- does not work :-(
...

D.

Thanks again Dominik

call method “objectForKey:” has been my friend more than once on this project. I will never forget her again! :smiley:

-sD-
Dr. Scotty Delicious, Scientist.