NSTableView View-Basedをコードで作りたい (3) [AppleScript辞書はつくれるか?]
TableView内のデータを読み取る。
列から取得する方法
set obj1 to item |行| of (theDataSource's |列|)
行から取得する方法
set obj1 to |列| of item |行| of theDataSource
2つあるけどどちらが便利なのだろう?
まぁ、列から取ってみる方法でやってみる。
setAllowsMultipleSelection_(true)
で複数行の選択を可能にし
set aList to {}
set firstNo to theSelection's firstIndex()
set nextIndex to firstNo
repeat selectionCount times
set data3 to theSelection's indexGreaterThanOrEqualToIndex:nextIndex
set aList to aList & {data3}
set nextIndex to data3 + 1
end repeat
で、選択された行のインデックスを取得
repeat with _lineNo in aList
set rowNo to _lineNo + 1
set obj1 to item rowNo of (theDataSource's data1)
set obj2 to item rowNo of (theDataSource's data2)
set obj3 to item rowNo of (theDataSource's data3)
set ans1 to (obj1's stringValue()) as text
set ans2 to obj2's state()
set ans3 to (obj3's value()) as real
log {ans1, ans2, ans3}
end repeat
で、それぞれの値を表示させている。
で、今回の全体のソースは『こちら』。
コメント 0