Partage
  • Partager sur Facebook
  • Partager sur Twitter

[AppleScript] NSTableView

récupérer la sélection

    2 septembre 2007 à 18:48:26

    Bonjour tout le monde :) ,

    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 :
    1. on clicked theObject
    2.         if the name of theObject is "bouton_info" then
    3.                 -- on "prend" la table (NSTableView)
    4.                 set authorTableView to table view "authorTableView" of scroll view "authorScrollView" of window "Main"
    5.                 -- prend le n° de la ligne sélectionée, puis l'affiche
    6.                 set rowIndex to clicked row of authorTableView
    7.                 display dialog "rowIndex = " & rowIndex
    8.                 -- si ce nombre > 0 (au moins une ligne sélectionnée)
    9.                 if rowIndex is greater than 0 then
    10.                         set selectedDataRows to selected data rows of authorTableView
    11.                         set un_Author to contents of data cell "author" of item 1 of selectedDataRows
    12.                         display dialog un_Author
    13.                 end if
    14.         end if
    15. 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.
    1. on clicked theObject
    2.         if the name of theObject is "bouton_info" then
    3.                 -- on "prend" la table (NSTableView)
    4.                 set authorTableView to table view "authorTableView" of scroll view "authorScrollView" of window "Main"
    5.                 set selectedDataRows to selected data rows of authorTableView
    6.                 if (count of selectedDataRows) > 0 then
    7.                         set groupe_name to contents of data cell "author" of last item of selectedDataRows -- sélection
    8.                         display dialog groupe_name
    9.                 end if
    10.         end if
    11. end clicked
    • Partager sur Facebook
    • Partager sur Twitter

    [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.
    • Editeur
    • Markdown