Groups | Blog | Home
all groups > flash actionscript > february 2006 >

flash actionscript : tabbing and focus


jonnybennett
2/19/2006 7:20:15 PM
I have 2 conflicting problems...

I have a lot of input text boxes that need to be focused and tabbable.
This following code sets focus correctly, but the tabbing doesn't work...

Selection.setFocus('iLoggin.inputLoggin');
iLoggin.inputLoggin.tabIndex=1;
iPassword.inputPassword.tabIndex=2;
iLoggin2.inputLoggin.tabIndex=3;
iPassword2.inputPassword.tabIndex=4;
iUser2.inputLoggin.tabIndex=5;

if I take out the setFocus, it still does not tab. If you press tab when you
select any of the input text boxes the focus does not change. If I take out one
of the lines (don't include it in the A.S.) eg...//
iLoggin2.inputLoggin.tabIndex=3;
When you now select this input textbox and press the tab key it tabs round all
the dynamically attached buttons. Therefore it must be registering that I have
created a tabIndex....
Does anyone know why this isn't working??????

To make matters worse, I tried creating a simplified tabbing experiment fla.
For the tabbing and focusing I used the folowing code...

nos1.inputMe.tabIndex=1;
nos2.inputMe.tabIndex=2;
nos3.inputMe.tabIndex=3;
nos4.inputMe.tabIndex=4;
nos5.inputMe.tabIndex=5;

Selection.setFocus('nos2.inputMe');

This also contained dynamically created buttons, to distract the tabbing. ON
this experiment, I found that the tabbing round the input text worked fine, but
no matter where I put the line...Selection.setFocus('nos2.inputMe'); I couldn't
set the focus....
aaaaaaaaaaahhhhhhhh... I can't see where I have gone wrong... Why oin one can
I set focus but not tab, and the exact opposite in the other, even though my
coding is the same..... Any help would be appreicated. Thanks J.

jonnybennett
2/19/2006 11:45:48 PM
Okay, the earlier post might not be particularly clear, perhaps we could start
with this...
place a textfield on the stage... give an instance name 'hello'. Add this
action script to the timeline....

stop();
Selection.setFocus("hello");

why is focus not set???????????????????????????aaaaaaaaaaaaahh.
jonnybennett
2/20/2006 12:00:00 AM
Okay the answer to part 2, is that the entire movie must have focus before you
can set focus to something else. Therefore you can either use javascript to set
focus to the movie, or make it so that the user has to press a button before it
gets to the page where you want to set focus, this will give the movie focus
and then the thing that you have coded to have focus.

Okay back to the first problem.... the tabbing issue. When I create the
following tab Index....

iLoggin.inputLoggin.tabIndex=1;
iPassword.inputPassword.tabIndex=2;
iLoggin2.inputLoggin.tabIndex=3;
iPassword2.inputPassword.tabIndex=4;
iUser2.inputLoggin.tabIndex=5;

if I select any of these input boxes and then tab, the cursor does not move.
However if I don't include this tab index in the code, when you select one of
the boxes and tab, the movie tabs around the buttons that are also on the
stage. Therefore the movie has registered that there is a tabIndex, however
there is something that is stopping it from functionoing correctly. Has anyone
ever had a problem like this????? any help would be good.
jonnybennett
2/20/2006 12:00:00 AM
Okay 24 hours later, we have an answer. The problem is that the textfields are
nested.
You would think the following code would enable the nested textfields to be
tabEnabled.

//iLoggin.inputLoggin.tabEnabled=true;
//iPassword.inputPassword.tabEnabled=true;
//iLoggin2.inputLoggin.tabEnabled=true;
//iPassword2.inputPassword.tabEnabled=true;
//iUser2.inputLoggin.tabEnabled=true;

However, you would be wrong. To enable the above 'nested' textFileds you must
use the following code.....

iLoggin.tabEnabled=false;
iPassword.tabEnabled=false;
iLoggin2.tabEnabled=false;
iPassword2.tabEnabled=false;
iUser2.tabEnabled=false;

iLoggin.tabChildren=true;
iPassword.tabChildren=true;
iLoggin2.tabChildren=true;
iPassword2.tabChildren=true;
iUser2.tabChildren=true;

// You can then include your tab index.

iLoggin.inputLoggin.tabIndex=1;
iPassword.inputPassword.tabIndex=2;
iUser2.inputLoggin.tabIndex=3;
iLoggin2.inputLoggin.tabIndex=4;
iPassword2.inputPassword.tabIndex=5;


I'd like to thank mainly me, for persisting with this problem. Well done.
Thanks for your help Jonny.
AddThis Social Bookmark Button