header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
NileshPawar
Points:280
Posts:0
Answered

5/12/2010 11:59:00 PM

Title: Itemrenderer's TextInput/TextArea focus problem on keyboard "Tab" key


Hello Members,

I am using TileList with custom itemrenderer. Custom itemrenderer creates form controls according to available items in Array Collection.

I am facing problem in textinput / textarea focus on keyboard "Tab" key.

Is there any way to get focus on next fields through keyboard "Tab" key?

Here is sample code of my example -


/* test.mxml */
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" layout="vertical">
<mx:Script>
	<![CDATA[
		import myItemRenderer;
		private var tempSelArray:Array=[
			{label: "I am CommonText", inputType:"CommonText"}, {label: "I am InputText 01", inputType:"CommonText"},
			{label: "I am TextArea 01", inputType:"AreaText"}, {label: "I am InputText 02", inputType:"CommonText"},
			{label: "I am TextArea 02", inputType:"AreaText"}, {label: "I am TextArea 03", inputType:"AreaText"},
			{label: "I am InputText 03", inputType:"CommonText"},{label: "I am InputText 04", inputType:"CommonText"}
		];
		
		private function init():void{
			addedFields.dataProvider = tempSelArray;
			addedFields.itemRenderer = new ClassFactory(myItemRenderer);
		}
	]]>
</mx:Script>
<mx:VBox width="100%" height="100%" >
  <mx:TileList id="addedFields" height="400" verticalScrollPolicy="off"
  	rollOverColor="0xffffff" selectionColor="0xffffff"
  	columnCount="1" columnWidth="{this.width-100}" rowHeight="50" width="100%" />
</mx:VBox>
</mx:Application>


/* myItemRenderer.mxml */

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.managers.IFocusManagerComponent" width="100%">
	<mx:Script>
		<![CDATA[
			import mx.containers.HBox;
			import mx.controls.Label;
			import mx.controls.TextArea;
			import mx.controls.TextInput;
			private var textField:TextInput = new TextInput();
			private var textArea:TextArea = new TextArea();
			private var textLabel:Label = new Label();
			
			private var hb:HBox = new HBox();
			
			override public function set data(value:Object):void
		    {
		        if(value != null)
		        {
		           super.data = value;
		           
		           textLabel.setStyle("color","0x000000");
		           textField.setStyle("color","0x000000");
		           textArea.setStyle("color","0x000000");
		           
		            switch(data.inputType){
		            	case("CommonText"):{
		            		textLabel.text = data.label + " :";
		            		// Create inputtextField and add to this
		            		hb.addChild(textLabel);
		            		hb.addChild(textField);
		            		this.addChild(hb);
		            	}
		            	break;
		            	case("AreaText"):{
		            		textLabel.text = data.label + " :";
		            		// Create inputtextArea and add to this
		            		hb.addChild(textLabel);
		            		hb.addChild(textArea);
		            		this.addChild(hb);
		            	}
		            	break;		            	
		            }
		        }
		    }
		]]>
	</mx:Script>	
</mx:Canvas>

Thanks, Nilesh



1
Madi
Points: 0
Posts:0
5/13/2010 2:56:44 AM



have you tried setting tabIndex property of textbox

2
NileshPawar
Points: 280
Posts:0
5/13/2010 4:47:57 AM



yes I have tried with tabIndex property but it wont works :(

3
NileshPawar
Points: 280
Posts:0
5/13/2010 10:27:25 PM



Can somebody please help me on this?

4
Inder
Points: 2980
Posts:0
5/13/2010 10:50:34 PM



Hi , Nilesh I am trying to fix it, Will get back to you as soon as get some positive result

5
Inder
Points: 2980
Posts:0
Accepted Answer
5/13/2010 11:08:48 PM



fixed it

to enable tabbing in the textfields inside your TileList component in flex. Set the property tabChildren="true" in mxml and extend the TileList component and use that component.


//MyTileList.as class extending the TileList compoenent, this class will enable tabEnabled property for children depending upon what you set in MXML.


package
{
	import mx.controls.TileList;
	
	public class MyTileList extends TileList
	{
		override protected function createChildren():void {
			super.createChildren();
			this.listContent.tabChildren = this.tabChildren
			this.listContent.tabEnabled = this.tabEnabled
		}
	}
}

In MXML use it by setting tabChildren=true : <local:MyTileList tabChildren="true" .....

6
NileshPawar
Points: 280
Posts:0
5/13/2010 11:30:22 PM



great, Thanks a lot Inder for your help!! :-) AskMeFlash Rockssssss

7
NileshPawar
Points: 280
Posts:0
5/13/2010 11:33:08 PM



I would say on your reply..... It's "Simply Amazing" doesn't have any other words!!
- Nilesh

8
Inder
Points: 2980
Posts:0
5/14/2010 1:07:11 AM



welcome :)

9
flexxx
Points: 150
Posts:0
7/7/2010 10:47:48 PM



Hi...
I am getting error for the same code on the following lines:

this.listContent.tabChildren = this.tabChildren
this.listContent.tabEnabled = this.tabEnabled

I am extending List....
Also I am using flex 4....I think these are the differences.
Any solution???

10
Inder
Points: 2980
Posts:0
Accepted Answer
7/8/2010 3:09:26 AM



use
hasFocusableChildren= true for spark List component in List tag .

11
sri
Points: 0
Posts:0
8/10/2010 11:36:38 AM



great work Inder.
hasFocusableChildren= true helped me a lot.

12
Rome
Points: 0
Posts:0
9/27/2010 2:29:21 AM



Hi,

I need your help.

I want to enable tab functionality in my item renderer.

My requirement is different. My item renderer extends UIComponent and create the textInput in create child.

I tried the above method for enabling the tab functionality, but it does not work.

Please help

13
Harry
Points: 0
Posts:0
2/9/2011 7:02:09 PM



I extended TileList and have overridden the createChildren method. My renderer is a VBOX with 4 textInputs. Focus works but gives an error each time I tab

TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls.listClasses::ListBaseContentHolder@3f205c1 to mx.managers.IFocusManagerComponent.
at mx.managers::FocusManager/sortFocusableObjectsTabIndex()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\FocusManager.as:646]
at mx.managers::FocusManager/sortFocusableObjects()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\FocusManager.as:729]
at mx.managers::FocusManager/keyDownHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\FocusManager.as:1296]


14
Kishore
Points: 0
Posts:0
7/14/2011 2:07:26 AM



Thankyou. It helped me a lot

15
lipper
Points: 0
Posts:0
10/27/2011 11:48:50 PM



Thanks. it's really useful


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+4 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions