Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default SetFocus Problem

    Hi Guys,

    I have a Problem. I have TextInput Object which has to be selected by default
    so that the user just start typeing anything in it when he first comes to that
    page. I tried using setFocus() to that but the problem here i am facing is the
    focus is draw on the component but i have to click in the TextInput to type in.

    So please can anybody solve it or give me an idea to resolve this problem.

    Srinivas S.M Guest

  2. Similar Questions and Discussions

    1. SetFocus
      I would like to set the focus automatically to one of the textbox controls on my page, but so far on every page I load I have to set the cursor to...
    2. problem with TextInput.setFocus() in Form
      The call setFocus on a TextInput in a form will not work unless the user has clicked on the movie. This means I have no way to set the default...
    3. setFocus();
      Hi! I have one start file(swf) where i select language from, and when i have selected a language i go to another swf file...
    4. Conditional setfocus
      "Mike Mueller" <mikemueller@ecinet.net> wrote: Mike, do you actually have table fields for each month for 2 years in one record? If so, you...
    5. textbox.setfocus
      Hello! Is it possible on a form to set the focus on a field without having the hole filed selected? cause if I use textbox.setfocus, the hole...
  3. #2

    Default setFocus problem

    hi there,

    i have an application that calls a login component i've made. in the login
    component i have a function which i call with creationComplete. this function
    basically resets the login form... here it is:

    private function resetLogin():void {
    username.text = "";
    password.text = "";
    username.setFocus();
    //var fManager:FocusManager = new FocusManager(this);
    //fManager.setFocus(username);
    }

    my problem is that setting the focus, whether i use FocusManager or simply say
    username.setFocus() doesn't seem to work... the focusRect is drawn, but the
    cursor doesn't focus within the username textInput area, which is the whole
    purpose for me setting focus.

    i've even tried calling the resetLogin function from the creationComplete
    event of the Application, thinking that maybe this was an issue with the
    application completing after the login component and stealing focus for some
    reason. but it doesn't work.

    does anyone know what i am doing wrong?

    thanks,
    nikki

    nif Guest

  4. #3

    Default Re: setFocus problem

    sorry... forgot to mention that when this method is called with a CloseEvent of an Alert, then it works perfectly fine. so the problem lies somewhere in the creationComplete area.
    nif Guest

  5. #4

    Default Re: setFocus problem

    Hi Nikki,

    1. Do you call this component immediately at the startup of an application?
    2. Do you use Firefox?

    If yes - there is a porblem with Firefox - it does not pass a focus to the
    loaded SWF automatically. Yoiu have to click on it first (or call an Alert()
    and it will make the trick).
    It works under IE though.

    If no - you probably have another problem setting a focus.
    Please read these threads:
    [url]http://tech.groups.yahoo.com/group/flexcoders/message/102706[/url]


    Cheers,
    Dmitri.

    Mitek17 Guest

  6. #5

    Default Re: setFocus problem

    hi dimitri,

    thanks for the reply.
    mine is on startup, but not only happening in firefox, so i guess it must be
    one of the other issues.

    i will check out the those threads.

    thanks a mil',
    nikki

    nif Guest

  7. #6

    Default Re: setFocus problem

    hi dimitri,

    i checked out that thread and tried the 2 suggested routes, but to no avail.
    the focusRect displays, but focus is still not in the textInput area that i am
    targetting.

    here is my code, can you see where i am going wrong?

    i call reset login from here:

    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="258" height="76"
    creationComplete="resetLogin()" keyUp="trySubmit(event)">

    and then this is in a script block below:

    public function resetLogin():void {
    username.text = "";
    password.text = "";
    this.callLater(this.callLater,[setupFocus]);
    }

    public function setupFocus():void {
    var fm:FocusManager = new FocusManager(this);
    fm.setFocus(username);
    fm.showFocus();
    var sm:SystemManager = new SystemManager();
    sm.activate(this);
    }

    thanks,
    nikki

    nif Guest

  8. #7

    Default Re: setFocus problem

    Nikki,

    Do you create this canvas using PopUpManager?

    I would try the following:

    private function setupFocus():void
    {
    username.setFocus()
    }

    And call this function from both creationComplete and updateComplete
    eventHandlers.

    PS In my quite complex case with multiple popups I ended up with simple
    component.setFocus() call, but I am calling it upon
    creationComplte/updateComplete with delay (callLater).

    PPS Did you try InternetExplorer? AFAIK Safari has this problem too.

    Mitek17 Guest

  9. #8

    Default Re: setFocus problem

    hi dimitri,

    i origionally had my code calling username.setFocus(), but graduated it to the
    higher grade focusManager version in a hope that it would work... i have
    reverted to the former with the delays in place, but to no avail.
    i have also tried running it on updateComplete, also to no avail... oh boy
    this is frustrating!

    also, to note, when i call the logout from elsewhere, like when i click on my
    logout button and thus return to the login screen, it works like a charm.

    the canvas is called into the root level of the app (from my app's main mxml
    file)... i think this is the problem, that it is called at application
    initialization.

    i have tried both ie and netscape... in fact i now compile into ie all the
    time as i was having speed issues with firefox on my box.

    i think i am going to try and call the login via as on creationComplete of the
    app and not an mxml tag... perhaps that'll do it.

    i will update here if it solves the problem... hold thumbs for me :)

    thanks,
    nikki



    nif Guest

  10. #9

    Default Re: setFocus problem

    *sigh*... nope, doesn't work. oh well, i guess the user will have to click in the username box when the app starts.
    unless anyone has any other ideas?
    nif Guest

  11. #10

    Default Re: setFocus problem

    Nikki,

    can you try to isolate the problem in you code and post it here?

    PS Don't give up. It should have a solution :)


    Cheers,
    Dmitri.
    Mitek17 Guest

  12. #11

    Default Re: setFocus problem

    hi dimitri,

    unfortunately i am stuck between a looming deadline and a hard place.
    i fully intend to relook this once all my work is complete, but in terms of
    priorities, this one has had to take a back seat to the entire sections i still
    need to create and finish up by thursday morning... *groan*

    when i relook, if i do find a solution, or at least figure out exactly what is
    causing the issue, i will definately post here.

    thanks for all of your help!
    nikki

    nif Guest

  13. #12

    Default Re: setFocus problem

    Quote Originally Posted by nif View Post
    hi there,

    i have an application that calls a login component i've made. in the login
    component i have a function which i call with creationComplete. this function
    basically resets the login form... here it is:

    private function resetLogin():void {
    username.text = "";
    password.text = "";
    username.setFocus();
    //var fManager:FocusManager = new FocusManager(this);
    //fManager.setFocus(username);
    }

    my problem is that setting the focus, whether i use FocusManager or simply say
    username.setFocus() doesn't seem to work... the focusRect is drawn, but the
    cursor doesn't focus within the username textInput area, which is the whole
    purpose for me setting focus.

    i've even tried calling the resetLogin function from the creationComplete
    event of the Application, thinking that maybe this was an issue with the
    application completing after the login component and stealing focus for some
    reason. but it doesn't work.

    does anyone know what i am doing wrong?

    thanks,
    nikki

    try this solution http://carrythezero.net/blog/page/2/
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139