Table View(テーブルビュー)を使う(4) [AppleScript辞書はつくれるか?]
Table View(4) -ダブルクリック-
前回(3)の続きです、
今回はダブルクリック処理です。
まず、コードを
script AppDelegate
property parent : class "NSObject"
property arrayController : missing value
property theData : {}
property tableView1 : missing value
property textField1 : missing value
これは、一番最初の頃に入力しておきながら全然使わなかったコードです。
忘れてました。テーブルビューの情報をやりとりします。なければ入力してください
delegate を右クリックして outlets から tableView1 をウインドウのTable View につなぎます。
on action3_()
(* 後で入力します *)
end action3_
と
on applicationWillFinishLaunching_(aNotification)
tell application "Finder"
set objList to name of (every item of folder (("/System/Library/Sounds" as POSIX file) as text))
end tell
set testData to {}
repeat with i from 1 to (count of objList)
set testData to testData & {{indexNo: i, data1: i, data2: (item i of objList)}}
end repeat
set my theData to testData
tableView1's setDoubleAction_("action3_")
end applicationWillFinishLaunching_
の黄色の部分を追加入力します。
わざわざ分けましたが、その後
on action3_()
tell ArrayController to set theSelect to selectionIndex()
set ans to "データの" & (theSelect +1) & "行目がダブルクリックされました"
textField1's setStringValue_(ans)
end action3_
の黄色の部分を追加入力します。
以上です。かんたんですね。
setDoubleAction は、テーブルビューの中で、ダブルアクション(ダブルクリック)が発生した場合に”action3_” というセレクション(ハンドラ)を実行しなさい。という命令です。
こんかいはここまで。(いいのかこれで)
コメント 0