I cannot figure out how table view works. Without giving me the example that comes with Xcode, can someone give me a very simple example of inserting a new row and deleting a row?
I don’t know if this will help, as I’m not terribly confident about the Table view myself, but I was just poring over this code in the Mail Search example.
on addMessage(messageFrom, messageSubject, messageMailbox)
-- Add a new row
set theRow to make new data row at the end of the data rows of data source of table view "messages" of scroll view "messages" of split view 1 of theWindow
-- Add "From" cell
set name of data cell 1 of theRow to "from"
set contents of data cell 1 of theRow to messageFrom
-- Add "Subject" cell
set name of data cell 2 of theRow to "subject"
set contents of data cell 2 of theRow to messageSubject
-- Add "Mailbox" cell
set name of data cell 3 of theRow to "mailbox"
set contents of data cell 3 of theRow to messageMailbox
end addMessage
Doesn’t cover deleting rows, but it’s pretty straight forward otherwise, I think. The first line of the subroutine adds the row (which is the worst part for sure…), the it sets a name and contents of each cell in the row.
Hope that helps!
I did find what looks like a very in depth article on the NSTableView class at the O’Rielly Mac Dev Center…don’t know if that’ll help or not (it’s all Objective-C), but it’s here.
Yes, I am working with Applescript.
Every time I put in the first line…
set theRow to make new data row at the end of the data rows of data source of table view "tblView" of scroll view "tblView" of window "Backup"
…I get the error…
Problem solved.
Hey, what was the answer? I’m struggling with the Table View myself right now…any thing I can soak would be helpful!
Well, I went a different route which worked, but then I couldn’t fill the table from text file so I am back to the same problem.
Check out my follow-up…
theTable variable not defined
Things that are really helping me are the examples. Check out the folder…
I got it finally. I am working with a data source. You have to make a connection by holding the CTRL key and dragging to the scroll view. Then connect it.
The With Data Source example really explains it.