Fix for wmode bug still existing in FireFox

I had written a post already for the fixed wmode bug in the new version of flash player in FireFox but now I have made almost complete fix for the issue. The issue itself is appearing when you try to use shift+arrows selection shortcut in TextInput field. So what I did was just to extend the TextInput class and use that. The implementation perhaps looks quite strange, but works! Still not working fully as expected though but I played with that too much time and couldn’t adjust it to work absolutely fine. So if anyone wants to spent some more time on the code hete it is:

package
{
	import mx.controls.TextInput;
	import mx.events.FlexEvent;
	import flash.events.KeyboardEvent;
	import flash.events.Event;
	import flash.ui.Keyboard;
	import flash.external.ExternalInterface;

	public class CafeTextInput extends TextInput
	{
		private var ssi : int = 0;
		private var sei : int = 0;
		private var shiftDirection : String = 'none';
		private var lastShiftDirection : String = 'none';

		public function CafeTextInput()
		{
			super();
			var method:XML = <![CDATA[
			     function( ){
			         return { ff: /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent), version:navigator.appVersion};}
			    ]]>
			var o:Object = ExternalInterface.call( method );

			if(o.ff)
			{
				this.addEventListener(KeyboardEvent.KEY_DOWN, onBeforeKeyDown, false, 10000);
				this.addEventListener(KeyboardEvent.KEY_DOWN, onAfterKeyDown, false, -10000);
			}
		}

		private function onBeforeKeyDown(e : KeyboardEvent) : void
        {
			if (e.keyCode == Keyboard.LEFT || e.keyCode == Keyboard.RIGHT)
			{
				if(ssi == -11111111 && sei == -11111111)
				{
					ssi = this.selectionBeginIndex;
					sei = this.selectionEndIndex;
				}
			}
        }

        private function onAfterKeyDown(e : KeyboardEvent) : void
        {
			if (e.keyCode == Keyboard.LEFT || e.keyCode == Keyboard.RIGHT)
			{
				if(ssi != -11111111 && sei != -11111111)
				{
					if(e.shiftKey)
					{
						if(sei == ssi)
						{
							shiftDirection = 'none';
						}

						if(e.keyCode == Keyboard.LEFT)
						{
							if(shiftDirection == 'right' && lastShiftDirection != 'right')
							{
								sei--;
							}
							if(shiftDirection == 'none' && ssi+1 == sei)
							{
								shiftDirection = 'left';
							}

							this.setSelection(sei, ssi);
							lastShiftDirection = 'left';
						}
						else if(e.keyCode == Keyboard.RIGHT)
						{
							if(shiftDirection == 'left' && lastShiftDirection != 'left')
							{
								ssi++;
							}
							if(shiftDirection == 'none' && ssi+1 == sei)
							{
								shiftDirection = 'right';
							}

							this.setSelection(ssi, sei);
							lastShiftDirection = 'right';
						}
					}
					else
					{
						shiftDirection = 'none';
						this.setSelection(ssi, sei);
					}

					ssi = -11111111;
					sei = -11111111;
				}
			}
                }
	}
}

This post is also available in: Bulgarian

  1. That’s not the case with WiFi calling, which enables you to send and receive calls and texts with a weak, or even non-existent signal as long as you’re connected to WiFi

  2. That the burden the FBI is putting on it by requesting that Apple write the software and assist in unlocking the device is too large. Apple argues that it would have to create the new version of iOS, called GovtOS, which requires coding, signing, verification and testing.

  1. No trackbacks yet.