A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Make enter key act like tab (change focus of input boxes)

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    247

    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.


  2. #2
    Challenging Convention Andology's Avatar
    Join Date
    May 2001
    Location
    Cyprus
    Posts
    152
    (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
    The Andology Corporation Ltd
    Challenging Convention
    Fusion of Business & Technology

    Joop Media - The Final Link In The Chain

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Posts
    247
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center