Return to Snippet

Revision: 5237
at February 21, 2008 10:06 by dhjapan


Initial Code
//util.FirefoxWmodeFix.fix(field);

class util.FirefoxWmodeFix {
	
	// [lettre écrite sous FF, bonne lettre, condition]
	public static var  FRENCH_KEYBOARD:Array = [
		["&", "1", Key.SHIFT],
		["é", "2", Key.SHIFT],
		["\"", "3", Key.SHIFT],
		["'", "4", Key.SHIFT],
		["(", "5", Key.SHIFT],
		["-", "6", Key.SHIFT],
		["è", "7", Key.SHIFT],
		["_", "8", Key.SHIFT],
		["ç", "9", Key.SHIFT],
		["à", "0", Key.SHIFT],
		
		["<", "?", Key.SHIFT],
		[":", ".", Key.SHIFT],
		["!", "§", Key.SHIFT],
		["ù", "%", Key.SHIFT],
		["$", "£", Key.SHIFT],
		["<", ">", Key.SHIFT],
	
		["\"", "#", Key.ALT],
		["'", "{", Key.ALT],
		["(", "[", Key.ALT],
		["-", "|", Key.ALT],
		["è", "", Key.ALT],
		["_", "\\", Key.ALT],
		["ç", "^", Key.ALT],
		["à", "@", Key.ALT]
	]
	
	public static var USED_KEYBOARD:Array
	
	
	public static function fix(_field:TextField) 
	{
		if(!USED_KEYBOARD) USED_KEYBOARD = FRENCH_KEYBOARD
		_field.addListener(FirefoxWmodeFix)
		_field.textLength = _field.text.length
	}
		
		
		
	
		

	
	private static function onChanged(_field):Boolean
	{
		// si on supprime une lettre, on ignore
		if (_field.textLength > _field.text.length) {
			_field.textLength = _field.text.length
			return false
		}else {
			_field.textLength = _field.text.length
		}
		
		
		var index = Selection.getBeginIndex()
		var newLetter = _field.text.substr(index - 1, 1)
		
		for (var i:Number = 0; i <USED_KEYBOARD.length ; i++) {
			if (USED_KEYBOARD[i][0] == newLetter) {
				if (Key.isDown(USED_KEYBOARD[i][2])) {
					_field.text = _field.text.substr(0, index - 1) + USED_KEYBOARD[i][1] + _field.text.substr(index)
					return true
				}
				/* ---===CAPSLOCK ne marche tout simplement pas sur firefox ===---
				 * 
				if (USED_KEYBOARD[i][2] == Key.CAPSLOCK && Key.isToggled(Key.CAPSLOCK) ) {
					_field.text = _field.text.substr(0, index - 1) + USED_KEYBOARD[i][1] + _field.text.substr(index)
					return true
				}
				*/
			}
		}
		
		
	}
	
	

}

Initial URL

                                

Initial Description
wmode=transparent ... input use system font.

Initial Title
FireFox wmode input fix

Initial Tags

                                

Initial Language
ActionScript