FireFox wmode input fix


/ Published in: ActionScript
Save to your folder(s)

wmode=transparent ... input use system font.


Copy this code and paste it in your HTML
  1. //util.FirefoxWmodeFix.fix(field);
  2.  
  3. class util.FirefoxWmodeFix {
  4.  
  5. // [lettre écrite sous FF, bonne lettre, condition]
  6. public static var FRENCH_KEYBOARD:Array = [
  7. ["&", "1", Key.SHIFT],
  8. ["é", "2", Key.SHIFT],
  9. ["\"", "3", Key.SHIFT],
  10. ["'", "4", Key.SHIFT],
  11. ["(", "5", Key.SHIFT],
  12. ["-", "6", Key.SHIFT],
  13. ["è", "7", Key.SHIFT],
  14. ["_", "8", Key.SHIFT],
  15. ["ç", "9", Key.SHIFT],
  16. ["à", "0", Key.SHIFT],
  17.  
  18. ["<", "?", Key.SHIFT],
  19. [":", ".", Key.SHIFT],
  20. ["!", "§", Key.SHIFT],
  21. ["ù", "%", Key.SHIFT],
  22. ["$", "£", Key.SHIFT],
  23. ["<", ">", Key.SHIFT],
  24.  
  25. ["\"", "#", Key.ALT],
  26. ["'", "{", Key.ALT],
  27. ["(", "[", Key.ALT],
  28. ["-", "|", Key.ALT],
  29. ["è", "", Key.ALT],
  30. ["_", "\\", Key.ALT],
  31. ["ç", "^", Key.ALT],
  32. ["à", "@", Key.ALT]
  33. ]
  34.  
  35. public static var USED_KEYBOARD:Array
  36.  
  37.  
  38. public static function fix(_field:TextField)
  39. {
  40. if(!USED_KEYBOARD) USED_KEYBOARD = FRENCH_KEYBOARD
  41. _field.addListener(FirefoxWmodeFix)
  42. _field.textLength = _field.text.length
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. private static function onChanged(_field):Boolean
  52. {
  53. // si on supprime une lettre, on ignore
  54. if (_field.textLength > _field.text.length) {
  55. _field.textLength = _field.text.length
  56. return false
  57. }else {
  58. _field.textLength = _field.text.length
  59. }
  60.  
  61.  
  62. var index = Selection.getBeginIndex()
  63. var newLetter = _field.text.substr(index - 1, 1)
  64.  
  65. for (var i:Number = 0; i <USED_KEYBOARD.length ; i++) {
  66. if (USED_KEYBOARD[i][0] == newLetter) {
  67. if (Key.isDown(USED_KEYBOARD[i][2])) {
  68. _field.text = _field.text.substr(0, index - 1) + USED_KEYBOARD[i][1] + _field.text.substr(index)
  69. return true
  70. }
  71. /* ---===CAPSLOCK ne marche tout simplement pas sur firefox ===---
  72. *
  73. if (USED_KEYBOARD[i][2] == Key.CAPSLOCK && Key.isToggled(Key.CAPSLOCK) ) {
  74. _field.text = _field.text.substr(0, index - 1) + USED_KEYBOARD[i][1] + _field.text.substr(index)
  75. return true
  76. }
  77. */
  78. }
  79. }
  80.  
  81.  
  82. }
  83.  
  84.  
  85.  
  86. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.