-
Make enter key act like tab (change focus of input boxes)
I am trying to make it so when a user hits the enter key the program will change focus from the different input boxes I have (like what the tab key does now).
I use the set focus and set it to like the instance name of my first input text, but it doesn't change there.
Code:
Selection.setFocus("_root.a")
trace(Selection.getFocus())
It traces _level0.a but on my screen if I type it doesn't show up in a.
-
Challenging Convention
(talking flash 5 here as i only code in v5 for best compatibilty)
it does not select the text box based on instance name but based on Var title.
Start your movie with frame one as:
setProperty(_root, _focusrect, false);
(stops crappy yellow rectangle showing if you use tab vs enter)
Initiate focus of first TextBox in timeline at same level as text box somewhere at the start:
Selection.setFocus("TextBox1");
Then create invisible button on stage and use code below as example:
on (keyPress "<Enter>") {
if (Selection.getFocus() == "_level0.TextBox1") {
Selection.setFocus("_level0.TextBox2");
} else if (Selection.getFocus() == "_level0.TextBox2") {
Selection.setFocus("_level0.TextBox3");
} else if (Selection.getFocus() == "_level0.TextBox3") {
Selection.setFocus("_level0.TextBox4");
} else if (Selection.getFocus() == "_level0.TextBox4") {
Selection.setFocus("_level0.TextBox5");
} else if (Selection.getFocus() == "_level0.TextBox5") {
Selection.setFocus("_level0.TextBox6");
} else if (Selection.getFocus() == "_level0.TextBox6") {
Selection.setFocus("_level0.TextBox7");
} else if (Selection.getFocus() == "_level0.TextBox7") {
Selection.setFocus("_level0.TextBox8");
} else {
}
}
Job done...
Cheers
Andy
-
thanks! The only part I can't get to work is
Initiate focus of first TextBox in timeline at same level as text box somewhere at the start:
Selection.setFocus("TextBox1");
I think I have read that it is an error with flash and the set focus command. I cannot get it to set the focus to something until the focus has been manually put on a text box by the user
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|