home *** CD-ROM | disk | FTP | other *** search
/ Comic Book Maker: The Smurfs / COMIC.iso / mac / data_m / dialog / 00040_fieldBhvr.ls < prev    next >
Encoding:
Text File  |  1999-07-07  |  1.6 KB  |  57 lines

  1. property pKeyApproveList, pNameMax
  2. global gPlatForm
  3.  
  4. on beginSprite me
  5.   if gPlatForm then
  6.     set pKeyApproveString to "!#$%&'()*+,-./0123456789;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~├ä├à├ç├ë├æ├û├£├í├á├ó├ñ├ú├Ñ├º├⌐├¿├¬├½├¡├¼├«├»├▒├│├▓├┤├╢├╡├║├╣├╗├╝ΓÇá┬░┬ó┬ú┬ºΓÇó┬╢├ƒ┬«┬⌐Γäó┬┤┬¿┬ì├å├ÿ┬É┬▒┬Å┼╜┬Ñ┬╡├░├¥├₧├╛┼á┬¬┬║├╜├ª├╕┬┐┬í╞Æ┬╝├É┬½┬╗ΓǪ┬á├Ç├â├ò┼Æ┼ô┬¡ΓÇöΓÇ£ΓÇ¥ΓÇÿΓÇÖ├╖├ù "
  7.     set pNameMax to 31
  8.   else
  9.     set pKeyApproveString to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_;"
  10.     set pNameMax to 8
  11.   end if
  12.   set pKeyApproveList to []
  13.   repeat with i = length(pKeyApproveString) down to 1
  14.     add(pKeyApproveList, charToNum(char i of pKeyApproveString))
  15.   end repeat
  16. end
  17.  
  18. on keyDown me
  19.   if (the key = RETURN) or (the key = ENTER) then
  20.     handleDefaultKeyDown(script 1)
  21.   end if
  22.   set keyNum to charToNum(the key)
  23.   if not getOne(pKeyApproveList, keyNum) then
  24.     stopEvent()
  25.   else
  26.     if not ((the key = BACKSPACE) or length(the selection)) then
  27.       if length(field "fileName") >= pNameMax then
  28.         puppetSound(1, "fieldFull")
  29.         stopEvent()
  30.       else
  31.         puppetSound(1, "key" & random(3))
  32.         pass()
  33.       end if
  34.     else
  35.       if the key = BACKSPACE then
  36.         puppetSound(1, "deleteKey")
  37.       else
  38.         puppetSound(1, "key" & random(3))
  39.       end if
  40.       pass()
  41.     end if
  42.   end if
  43. end
  44.  
  45. on keyUp me
  46.   set theLength to length(field "fileName")
  47.   if theLength >= pNameMax then
  48.     set the text of member "fileName" to char 1 to pNameMax of field "fileName"
  49.   end if
  50.   if not theLength then
  51.     disable(sprite(4))
  52.   else
  53.     enable(sprite(4))
  54.   end if
  55.   updateStage()
  56. end
  57.