Select to view content in your preferred language

Custom tab function

1144
2
01-29-2011 05:52 AM
WesBailes
Occasional Contributor
I understand that this should be on a general flex forum but i haven't found a good one yet.

I have a need for a custom tab function for use between textinput controls. The only way that it works is if I call Alert.show("something"); after the command. At the top of the application, I have the tabChildren set to false.* event listener declaration code:*

textInput1.setFocus();
textInput2.addEventListener(KeyboardEvent.KEY_DOWN ,kH);

* handler code is:*

private function kH(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.TAB) {*
textinput2.setFocus();
//only works with the following line uncommented*****
//Alert.show("made it"); } }* Any suggestions are appreciated!
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Wes,

   Here is a sample of this working:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      minWidth="955" minHeight="600" tabChildren="false"
      creationComplete="init()">
 <s:layout>
  <s:VerticalLayout gap="4"/>
 </s:layout>
 <fx:Script>
  <![CDATA[
   private function init():void
   {
    //This code is needed to give the flex application itself the focus
                                //The getElementById('Wes') Wes is the name of the application.
    navigateToURL(new URLRequest("javascript: document.getElementById('Wes').focus();"), "_self");
    //Now give the focus to the first input 
    textInput1.setFocus();
    textInput1.addEventListener(KeyboardEvent.KEY_DOWN ,kH);
   }
   
   private function kH(event:KeyboardEvent):void {
    if (event.keyCode == Keyboard.TAB) {
     textInput2.setFocus(); 
    }
   }
  ]]>
 </fx:Script>
 <s:TextInput id="textInput1" text="hello" />
 <s:TextInput id="textInput2" text="good bye" />
</s:Application>
0 Kudos
WesBailes
Occasional Contributor
Thanks Robert!  Works great.
0 Kudos