Je débute en AppleScript, et je souhaite récupérer le contenu d'une cellule sélectionnée dans un NSTableView.
Voici mon code :
on clicked theObject
if the name of theObject is "bouton_info" then
-- on "prend" la table (NSTableView)
set authorTableView to table view "authorTableView" of scroll view "authorScrollView" of window "Main"
-- prend le n° de la ligne sélectionée, puis l'affiche
set rowIndex to clicked row of authorTableView
display dialog "rowIndex = " & rowIndex
-- si ce nombre > 0 (au moins une ligne sélectionnée)
if rowIndex is greater than 0 then
set selectedDataRows to selected data rows of authorTableView
set un_Author to contents of data cell "author" of item 1 of selectedDataRows
display dialog un_Author
end if
end if
end clicked
Etrangement, le nombre de lignes sélectionnées est à 0, alors qu'il devrait être à 1 (puisque j'ai effectivement sélectionné une ligne).
Où est ma faute ?
Merci d'avance !
Guillom.
Edit : j'ai utilisé une autre approche, et mon problème est maintenant résolu. Cependant, j'aimerais comprendre pourquoi mon code ne fonctionnait pas.
on clicked theObject
if the name of theObject is "bouton_info" then
-- on "prend" la table (NSTableView)
set authorTableView to table view "authorTableView" of scroll view "authorScrollView" of window "Main"
set selectedDataRows to selected data rows of authorTableView
if (count of selectedDataRows) > 0 then
set groupe_name to contents of data cell "author" of last item of selectedDataRows -- sélection
display dialog groupe_name
end if
end if
end clicked
[AppleScript] NSTableView
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.