[OPEN] [#310] Window.DefaultFocus problem

  1. #1

    [OPEN] [#310] Window.DefaultFocus problem

    Could you explain how DefaultFocus is supposed to work? Documentation says ("The id of a button to focus when this window received the focus.")

    This isn't working for me. See example.

    Also, what is AutoFocus="true" supposed to do and how is it different?

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    </script>
    
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Test</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport ID="vp" runat="server" Layout="VBoxLayout">
            <LayoutConfig>
                <ext:VBoxLayoutConfig Align="Stretch" />
            </LayoutConfig>
            <Items>
    
    
                <ext:Window ID="Panel1" runat="server" Border="false" BodyBorder="0" BodyCls="BodyFrame" Layout="HBoxLayout" DefaultFocus="STitleE" Width="200">
                <LayoutConfig>
                    <ext:HBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
    
    
                    <ext:Container runat="server" Flex="1">
                    <Items>
                        <ext:Panel ID="Panel2" runat="server" Border="false" BodyBorder="0" MarginSpec="0 2px" Height="100" Frame="true">
                            <Items>
                                <ext:Label runat="server" Html="Test" Height="100" />
                                <ext:TextField ID="STitleE" runat="server" MaxLengthText="12" MaxLength="12" Width="94" EnforceMaxLength="true"
                                     MinLength="2" AllowBlank="false" CausesValidation="true" AutoFocus="true" />
                            </Items>
                        </ext:Panel>
    
                    </Items>
                    </ext:Container>
    
                </Items>
            </ext:Window>
    
    
        </Items>
        </ext:Viewport>
    
        </form>
    </body>
    </html>
    Last edited by Daniil; Aug 02, 2013 at 4:52 AM. Reason: [OPEN] [#310]
  2. #2
    Hi @michaeld,

    As for the DefaultFocus it is a bug.
    http://www.sencha.com/forum/showthread.php?266701

    Please see the last post where I propose possible solutions.

    Created an Issue to track it.
    https://github.com/extnet/Ext.NET/issues/310

    As for the AutoFocus option.

    The difference from the DefaultFocus is: it should be set up for a focused Component, not for its Container.

    However, it appears to be broken as well. Fixed in SVN.

    Thank you for the report!
  3. #3
    Quote Originally Posted by Daniil View Post
    As for the DefaultFocus it is a bug.
    http://www.sencha.com/forum/showthread.php?266701
    Please see the last post where I propose possible solutions.
    I noticed the solutions you added, but how come you didn't add your suggestion to ext.net trunk as an override? It seems to me that you often do so until such time as it's addressed in extjs? It could be an undetermined amount of time till 4.3 after all.

    Quote Originally Posted by Daniil View Post
    As for the AutoFocus option.
    The difference from the DefaultFocus is: it should be set up for a focused Component, not for its Container.
    However, it appears to be broken as well. Fixed in SVN.
    Thank you for the report!
    Still a little confused how AutoFocus="true" works. Do I set this to a single control in a form for the control that I want to have focus set to when the window shows or renders? That is, all other controls are set to AutoFocus="false", the default? What happens if 2 controls have AutoFocus="true"

    Not sure I understand the mechanism yet.
  4. #4
    Quote Originally Posted by michaeld View Post
    I noticed the solutions you added, but how come you didn't add your suggestion to ext.net trunk as an override? It seems to me that you often do so until such time as it's addressed in extjs? It could be an undetermined amount of time till 4.3 after all.
    Yes, it is a common practice but depends on circumstances. In this case everything looks good to commit it to SVN. So, done. Thank you again for the report.

    Quote Originally Posted by michaeld View Post
    Still a little confused how AutoFocus="true" works. Do I set this to a single control in a form for the control that I want to have focus set to when the window shows or renders? That is, all other controls are set to AutoFocus="false", the default? What happens if 2 controls have AutoFocus="true"

    Not sure I understand the mechanism yet.
    AutoFocus="true" just focuses a Component within its AfterRender listener with AutoFocusDelay. AutoFocus is true, AutoFocusDelay is 10 be default.

    There is no check if AutoFocus set up for several components. So, it is under developer's responsibility.
  5. #5
    Thanks!

    I'll try it out.

    Oh, you didn't answer what happens when 2 controls have autofocus=true
  6. #6
    Sorry, I thought I answered by this:)

    Quote Originally Posted by Daniil View Post
    There is no check if AutoFocus set up for several components. So, it is under developer's responsibility.
    I meant that it should be not set up for components which are rendered at the same time, because two components cannot be focused simultaneously. Well, nothing critical will happen, I mean no exception, error, just some component will be focused. Probably, the one which is rendered later.

    But it should be OK to set up AutoFocus="true" for components from, for example, in different Windows. Though, please note it will be focused only on initial rendering, not on further appearances. But DefaultFocus should focus in that case. So, it is probably a better choice.

Similar Threads

  1. Problem with window?
    By freelandcer in forum 2.x Help
    Replies: 2
    Last Post: May 07, 2013, 2:34 AM
  2. [CLOSED] Problem: Closing Maximized Window will loose parent window scrollbar
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 19, 2012, 8:51 PM
  3. WIndow Height Problem
    By threewonders in forum 1.x Help
    Replies: 6
    Last Post: Jun 20, 2011, 7:38 AM
  4. problem with window
    By a.amirkhani in forum 1.x Help
    Replies: 0
    Last Post: Apr 23, 2011, 9:30 AM
  5. [CLOSED] Problem to close Window which has another Window inside
    By asztern in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 21, 2010, 5:33 PM

Posting Permissions