OK, I’ve searched through the forums and haven’t found an answer to what I think is a very simple question. In 3 Pane view, it’s easy to have the files contained in a group listed in the top pane. What I haven’t been able to do is select one of those files and have the content shown in the bottom pane. Here’s a little test snippet:
tell application "DEVONthink Pro"
set myGroup to create location "/Test Group"
set myRecord to create record with {name:"Test file", rich text:"Hello there!" & return, type:rtf, tags:"test"} in myGroup
-- In 3 Pane view:
-- The following line shows the list of docs in the top window pane
set root of viewer window 1 to myGroup
-- The following line doesn't show the contents in the lower view/edit pane
-- What are the magic words?? :-)
set selection of viewer window 1 to record "Test file"
end tell
What does one have to do to show content in the bottom pane and not open up a new window with the ‘open window for’ code?
I’m not opening a 3 pane view, I’m always in 3 pane view. I have a script that I keep in the toolbar called ‘Journal’. It creates a new rich text file named with the date. It creates the file in a group named for the year-month such as ‘2013-10’. When Journal creates the file, I’d like to display the files in that group in the top pane and the contents of the newly created note in the bottom pane.
I can’t imagine why a script would be able to display a list of files in a group in the top and then not be able to display the contents of any of them in the bottom??
This “should” work, but it wrongly opens an excess tab instead of a tab for the designated record. Would be useful if the components of “think window” could be set directly – not possible yet, AFAIK.
tell application "DEVONthink Pro"
set myGroup to create location "/Test Group"
set myRecord to create record with {name:"Test file", rich text:"Hello there!" & return, type:rtf, tags:"test"} in myGroup
set root of viewer window 1 to myGroup
open tab for record myRecord in think window 1
end tell
Thanks for the open tab idea Korm. I think I have it. Try this:
tell application "DEVONthink Pro"
set myGroup to create location "/Test Group"
set myRecord to create record with {name:"Test file", rich text:"Hello there!" & return, type:rtf, tags:"test"} in myGroup
set root of viewer window 1 to myGroup
open tab for record myRecord in viewer window 1
close first tab in viewer window 1
end tell
Thanks Korm, the big thing that still escapes me is how to highlight the file in the upper pane whose content is showing in the lower one. Maybe a future version of DTPO will make this a little more straight forward!
@Korm- I figured out an easy way to highlight the active file in the upper pane…clear any labels set for the existing files and set a label for the newly created or changed file:
tell application "DEVONthink Pro"
set myGroup to create location "/Test Group"
set visWin to viewer window 1
tell visWin
set root to myGroup
set label of every child in myGroup to 0
set myRecord to create record with {name:"Test file", rich text:"Hello there!", type:rtf, label:5, tags:"test"} in myGroup
open tab for record myRecord in visWin
close first tab
end tell
end tell