[CLOSED] press the ENTER key

  1. #1

    [CLOSED] press the ENTER key

    I found a solution that solved my problem, thanks.

    But I have a question about the button.

    Is there any way to press the ENTER key to perform the click of a button specific?

    Was using the following function for asp button

    But I can run the button click anywhere on the page you need not only be fired in the combo.


    <script type="text/javascript">
            function TrataEnter() {
     
                if (event.keyCode == 13) {
                    document.getElementById("btnLogin").click();
                }
            }
        </script>
    <ext:ComboBox ID="cmbAmbDados" runat="server" StoreID="StorecmbAmbDados" DisplayField="Text"
                                FieldLabel="Ambiente" ValueField="Value" Mode="Local" Width="255" IndicatorTip="Ambiente de Dados"
                                LabelAlign="Right">
                                <Template runat="server" Visible="False" ID="ctl265" EnableViewState="False">
                                </Template>
                                <Listeners>
                                    <KeyDown Fn="TrataEnter" />
                                </Listeners>
                            </ext:ComboBox>
    Last edited by Daniil; Jun 07, 2011 at 10:52 PM. Reason: [CLOSED]
  2. #2
    Hi,

    For Ext.Net.Button please use .fireEvent();
    Button1.fireEvent('click');
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    For Ext.Net.Button please use .fireEvent();
    Button1.fireEvent('click');
    I would like to capture the ENTER anywhere on the screen.
    Eg if I'm with the focus on field1 and then press ENTER it performs the event of the button.
    The controls are within a FormPanel
    Is it possible?
  4. #4
    Within DocumentReady listener of ResourceManager call:
    Ext.getDoc().on('keydown', function (e) {
        if (e.getKey() == e.ENTER) {
            Button1.fireEvent('click');
        }
    });
    Last edited by Daniil; Jun 07, 2011 at 9:47 PM. Reason: Replaced '=' with '=='
  5. #5
    Quote Originally Posted by Daniil View Post
    Within DocumentReady listener of ResourceManager call:
    Ext.getDoc().on('keydown', function (e) {
        if (e.getKey() = e.ENTER) {
            Button1.fireEvent('click');
        }
    });
    I tried the following:
    <ext:ResourceManager ID="ResourceManager1" runat="server">
            <Listeners>
                <DocumentReady Handler="Ext.getDoc().on('keydown', function (e) {if (e.getKey() = e.ENTER) {btnLogin.fireEvent('click');}});" />
            </Listeners>
        </ext:ResourceManager>
    But is giving the following error.
    Runtime Error in Microsoft JScript: Can not assign the result of a function
  6. #6
    Hi,

    You have to use '==' instead '='
  7. #7
    Quote Originally Posted by Vladimir View Post
    Hi,

    You have to use '==' instead '='
    Ok, thanks.
  8. #8
    Could you show how this would work with MVC/Razor? I'm trying:

    @(Html.X().ResourceManager()
        .Listeners(listener => {
            listener.DocumentReady.Handler = "Ext.getDoc().on('keydown', function (e) {if (e.getKey() == e.ENTER) {LoginButton.fireEvent('click');}});";
        })
    )
    but this gives me an "invalid argument" error on LoginButton,fireEvent('click')
  9. #9
    What about App.LoginButton instead LoginButton?
  10. #10
    That worked, thank you!

Similar Threads

  1. Press Enter key should work on search button
    By Nagaraju in forum 1.x Help
    Replies: 1
    Last Post: Oct 09, 2011, 5:09 PM
  2. How do press Enter key jump like Tab?
    By whs2893 in forum 1.x Help
    Replies: 6
    Last Post: Mar 23, 2011, 3:07 AM
  3. [CLOSED] pop up a page when i press a key on key board
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 15, 2010, 3:55 PM
  4. TextField Key press event
    By maruf.zaman in forum 1.x Help
    Replies: 1
    Last Post: Nov 30, 2010, 9:29 AM
  5. Replies: 0
    Last Post: Sep 10, 2009, 8:59 AM

Posting Permissions