Comment initialiser un text field en AppleScript?
J'ai testé cela sans succès (rien ne se passe):
Mon "text field" reste désespérément vide.Code:set contents of text field "lannee" of window "facturation" to "2007"
Version imprimable
Comment initialiser un text field en AppleScript?
J'ai testé cela sans succès (rien ne se passe):
Mon "text field" reste désespérément vide.Code:set contents of text field "lannee" of window "facturation" to "2007"
Tu ne peux pas mettre un peu plus de code ?
Avec ça, on ne peut pas trop comprend.
;)
Si bien sûr:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 -- ExtraireDB.applescript -- ExtraireDB -- Created by Rocou on 18/10/07. -- Copyright 2007 __MyCompanyName__. All rights reserved. -- ces initialisations ne fonctionnent pas pour une raison encore inconnue set contents of text field "LeClient" of box "SelectionClient" of window "facturation" to "" set contents of text field "lannee" of window "facturation" to "2007" on clicked theObject --récupérer l'année par défaut ou l'année saisie set MonAnnee to contents of text field "lannee" of window "facturation" if MonAnnee = "" then set MonAnnee to year of (current date) end if if the name of theObject is "Validation" then --récupérer le mois et le commercial set ChoixMois to title of popup button "LeMois" of window "facturation" if (ChoixMois is in {"Janvier", "Mars", "Mai", "Juillet", "Août", "Octobre", "Décembre"}) then set JourFin to "31" else if (ChoixMois is in {"Avril", "Juin", "Septembre", "Novembre"}) then set JourFin to "30" else if (ChoixMois is in {"Février"}) then set JourFin to "29" -- il n'est pas utile de gérer les années bisextiles end if end if end if -- Le script SQL appelé plus loin à besoin de la date de -- début de mois et la date de fin de mois -- construction d'une date du style "25 janvier 2007" set datedeb to "01" & " " & ChoixMois & " " & MonAnnee set datedeb to date datedeb -- transformation d'une date du style "jj mmm aaaa" en -- date du style "2007-01-25" set ChoixMois to month of datedeb set ChoixMois to ChoixMois as integer set lemois to ChoixMois as string set longueurChaine to length of lemois if longueurChaine is less than 2 then set lemois to "0" & lemois end if --set datedebut to "01" & ChoixMois & year of (current date) set datedebut to MonAnnee & "-" & ChoixMois & "-" & "01" as string --la date de fin de mois set datefin to JourFin & " " & ChoixMois & " " & MonAnnee set datefin to date datefin -- transformation d'une date du style "jj mmm aaaa" en -- date du style "2007-01-25" set ChoixMois to month of datefin set ChoixMois to ChoixMois as integer set lemois to ChoixMois as string set longueurChaine to length of lemois if longueurChaine is less than 2 then set ChoixMois to "0" & ChoixMois end if --set datefin to year of (current date) & ChoixMois & "01" --set datefin to JourFin & ChoixMois & year of (current date) set datefin to MonAnnee & "-" & ChoixMois & "-" & JourFin as string set ChoixCommercial to title of popup button "LeCommercial" of window "facturation" if (ChoixCommercial = "Alexis") then set ChoixCommercial to "9" else if (ChoixCommercial = "Hubert") then set ChoixCommercial to "10" else if (ChoixCommercial = "Thierry") then set ChoixCommercial to "11" else if (ChoixCommercial = "Cecile") then set ChoixCommercial to "12" end if if (ChoixCommercial = "Tous") then set ChoixCommercial to "%%" end if end if end if end if set ChoixClient to "" set ChoixClient to contents of text field "LeClient" of box "SelectionClient" of window "facturation" set ChoixClient to "%" & ChoixClient & "%" --lancer la procédure d'extraction -- code interne confidentiel end if end clicked
Et comment veux-tu que cela fonctionne ? Le code n'est exécuté que s'il est appelé, or tes deux lignes ne seront pas appelées tant qu'elles ne seront pas placées dans la méthode AppleScript appropriée (par exemple dans la méthode on launched qui est appelée lors du lancement du logiciel).
Peut-on voir le code que tu as écrit ?
Si ça ne fonctionne pas avec on launched il est possible que on awake from nib résolve le problème. Cette méthode est appelée lorsque l'interface utilisateur a été entièrement construite, ce qui garantit que tes opérations sur les objets de l'interface ne se feront pas dans le vide.
P.S.: j'aurais dû commencer par te parler de on awake from nib :(.
En ouvrant le document .nib avec Interface Builder, partie AppleScript dans la fenêtre d'informations, la case "awake from nib" est cochée ainsi que le fichier .applescript correspondant ?