tu vérifies la longueur de 'recherche' à l'aide de
if (member("recherche").char.count<>4) then
ton script
end if
si l'utilisateur peut appuyer sur 'enter' pour valider sa saisie
if (member("recherche").char(member("recherche").char.count))=RETURN) then
delete member("recherche").char(member("recherche").char.count)
end if
et là tu vérifies
Khone
Voici un petit comportement paramétrable à associer à ton champ de
recherche :
---------------------------------------------------------------
property Caracteres
property NbMax
property NbMin
on keyDown me
if [51,117,123,124,125,126].getPos(the keyCode) then
-- backspace, suppr, arrow keys
pass
end if
leChamp = sprite(me.spriteNum).member
if Caracteres contains the key and leChamp.text.char.count < NbMax then
pass
else
if the key = RETURN and leChamp.text.char.count >= NbMin then
--Placer ici le code lorsqu'on tape sur Entrée
alert "OK"
else
beep
dontPassEvent
end if
end if
end keyDown
on getPropertyDescriptionList me
return \
[\
#Caracteres: \
[ \
#comment: "Caractères acceptés :", \
#format: #string, \
#default: "0123456789" \
],\
#NbMax:\
[ \
#comment: "Nombre de caractères maxi :", \
#format: #integer, \
#default: 4 \
],\
#NbMin:\
[ \
#comment: "Nombre de caractères mini :", \
#format: #integer, \
#default: 4 \
]\
]
end getPropertyDescriptionList
---------------------------------------------------------------
A+
Lionel Morin