Définir dernier item sélectionné comme item par défaut

Volodia Dimitri

Membre enregistré
23 Avril 2020
2
0
53
Bonjour,

J'espère que quelqu'un va pouvoir m'aider car je n'ai rien trouvé sur la toile traitant de ce sujet
J'ai fait un menu déroulant sur Indesign en Applescript qui contient plusieurs item et qui se lance à l'ouverture d'un document Indesign.

A chaque ouverture de document, ce menu déroulant apparait et par défaut est sélectionné la première valeur (premier item).

Je voulais savoir s'il était possible qu'à chaque ouverture d'un nouveau document Indesign, le menu déroulant propose le dernier item utilisé ?

Autrement dit, le menu déroulant peut-il garder en mémoire le dernier item utilisé ?

Je ne sais pas trop comment procédé, j'ai même essayé de copier l'item sélectionné dans un fichier texte et je voulais indiquer au menu déroulant qu'il fallait afficher la prochain fois cet item mais là je bloque.

Quelqu'un peut m'aider ?

Merci.
 
Complément d'info :
Pour info, je fais appel à un fichier .csv (qui est sur mon bureau) qui contient les données de mes items.
Je voudrais que dans le menu déroulant s'affiche de dernier item de la colonne_A utilisé précédemment.
Ci-dessous mon code actuel :


tell application "Finder"
set the_file to ((path to desktop as text) & "Formats_Pubs.csv") as alias
end tell

set my_data to read the_file
set my_list to paragraphs of my_data as list

set ColumnA_list to {}
set ColumnC_list to {}
set ColumnD_list to {}


set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ";"



repeat with an_item in my_list
try
set end of ColumnA_list to text item 1 of an_item
set end of ColumnC_list to text item 3 of an_item
set end of ColumnD_list to text item 4 of an_item
end try
end repeat

set AppleScript's text item delimiters to oldDelims


tell application "Adobe InDesign CC 2018"

activate

set varDropDownList to ColumnA_list
set varSelectedIndex to 1
set varMinimumWidth to 150
set myEventNames to {"afterNew", "afterUpdate", "afterInvoke", "afterActivate", "afterContextChanged", "afterSelectionAttributeChanged", "afterSelectionChanged", "beforeUpdate"}
set myDialog to make dialog with properties {name:"CHOIX DU FORMAT :"}

tell myDialog
tell (make dialog column)
tell (make border panel)
tell (make dialog column)
tell (make dialog row)

---- DRODPDOWN
make static text with properties {static label:"LISTE DES FORMATS : "}
set varDropDown to make dropdown with properties {string list:varDropDownList, selected index:(varSelectedIndex - 1), min width:varMinimumWidth}
tell varDropDown
repeat with myEventName in myEventNames
make event listener with properties {event type:myEventName, handler:my dropdownchange}
end repeat
end tell
end tell
end tell
end tell
end tell
end tell

--get the results
set myResult to show myDialog
if myResult = true then
-- varDropDown Handler (Dropdown)
set varSelectedIndex to ((selected index of varDropDown) + 1)
set varDropDownListChoice to item varSelectedIndex of varDropDownList as item
end if
destroy myDialog
end tell

on dropdownchange()
tell application "Adobe InDesign CC 2018"
set myEvent to evt
display dialog ("This event is the " & event type of myEvent & " event.")
end tell
end dropdownchange

set the_position to indexof(varDropDownListChoice, ColumnA_list)
if the_position is 0 then
tell application "Finder"
activate
display dialog "The search term does not exist in Column D."
end tell
return
end if


if the_position is 1 then
tell application "Finder"
activate
display dialog "Veuillez choisir un format valable"
end tell
return
end if


on indexof(theItem, theList)
set text item delimiters to return
set theList to return & theList & return
set text item delimiters to {""}
try
-1 + (count (paragraphs of (text 1 thru (offset of (return & theItem & return) in theList) of theList)))
on error
0
end try

end indexof