[CLOSED] Focus TextField if Window Hide=true

  1. #1

    [CLOSED] Focus TextField if Window Hide=true

    Hello,

    I am using a TextField in a Window which is not initially loaded (Hidden=true):

        <ext:Window ID="Window1" runat="server" Icon="Pencil"   Hidden="true" Title="Aufenthaltsort"
            Height="200px" Width="400px" Closable="False">
            <Content>
       
                <ext:TextField ID="textLocation" runat="server" AllowBlank="False" Width="300px" 
                    Style="font-size: large" EnableKeyEvents="true">
                    <Listeners>
                     <KeyPress Handler="if ((e.getKey() == e.ENTER)) {
                                            #{DirectMethods}.btnSave_Click();
                                        }" />
                    </Listeners>
                    </ext:TextField>
                  </Content>
            <Buttons>
                <ext:Button ID="btnCancel" runat="server" Icon="Cancel" Style="text-align: right"
                    Text="Abbrechen">
                    <Listeners>
                        <Click Handler="#{DirectMethods}.btnCancel_Click();" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="btnSave" runat="server" Icon="Disk" Text="Speichern">
                    <Listeners>
                        <Click Handler="#{DirectMethods}.btnSave_Click();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Listeners>
                <AfterLayout Handler="#{textLocation}.focus();" />
            </Listeners>
        </ext:Window>

    I cannot use the
     <AfterLayout Handler="#{textLocation}.focus();" />
    because the textLocation TextField is not initially rendered (Firebug-Message: textLocation is not defined) if I set the window to hidden=true.

    What do I have to do to solve this?


    I am sure that I have already read about this problem here in the board but cannot find it anymore.


    Regards,

    Martin
    Last edited by geoffrey.mcgill; Jul 15, 2010 at 12:42 AM.
  2. #2
    Hi,

    Just change AfterLayout event by Show (because you don't use layout, you use Content) and add small Delay
    <Listeners>
        <Show Handler="#{textLocation}.focus();" Delay="50" />
    </Listeners>
    It is better to use Items instead Content. In this case AfterLayout will work
    <Listeners>
           <AfterLayout Handler="#{textLocation}.focus();" Delay="50" />
    </Listeners>

    Also there is AutoFocus property (please update from SVN first). In this case that listener is not required
    AutoFocus="true" AutoFocusDelay="50"

Similar Threads

  1. Replies: 10
    Last Post: Apr 25, 2013, 5:38 AM
  2. [CLOSED] Set focus to TextField once Window is visible
    By digitek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 13, 2012, 11:45 AM
  3. [CLOSED] How to focus TextField in Window?
    By macap in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 14, 2010, 8:18 AM
  4. Set focus on TextField after window load
    By sfvaleriano in forum 1.x Help
    Replies: 0
    Last Post: Oct 15, 2009, 8:27 AM
  5. [CLOSED] Set Focus to textfield in logon window
    By HOWARDJ in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 17, 2009, 9:41 PM

Posting Permissions