Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: How to put keybord event to formPanel?

  1. #1

    Default How to put keybord event to formPanel?

    Hi,

    I want to know how it's possible to submit a form with the key "enter".

    I use a formPanel, I have test:

    myformPanel.on("keypress",function(e){
    alert("event"+e.getKey());
    });

    and

    myformPanel.addListener("onkeypress",function(e){
    alert("event"+e.getKey());
    });
    but it's don't work, I don't have an alert.

    Thanks

    Jim

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    The first one (without the 'on') is correct.

    But it doesn't work, because the element inside the form 'steal' the enter key.

    Fortunately there is a better solution.

  3. #3

    Default

    Thanks it's just what I want but I don't know how to implement this because I use panelForm and not BasicForm.
    Do you have an example who implement this please.

    Thanks

    Jim

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    If you don't have a <form> tag you're stuck with adding a keydown handler to every field on the panel.

  5. #5

    Default

    If I understand I have to change my formPanel to a basicForm?

    If I don't have another choice ^^ . Do you have an example with basicForm with submit on enter?

    Thanks

    Jim

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    A FormPanel contains a BasicForm (see the API docs for FormPanel.getForm) and it is created with the same config options (except listeners).

    So Animals override also adds for a submitOnEnter config option in FormPanel.

  7. #7

    Default

    I have try to put "submitOnEnter:true," in parameter of my formPanel and firebug give me

    Ext.isObject is not a function
    [IMG]chrome://firebug/content/blank.gif[/IMG] this.submit(Ext.isOb...er) ? this.submitOnEnter : undefined);\r\n

    I use ExtJS on mapfish not ExtJS 3.0, it's a problem?

    Thanks for help

    Jim

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    It's an Ext 3.0 override. You would need to modify it for Ext 2.x.

  9. #9

    Default

    I try to adapt the overide of animal but I don't understand this line:

    this.submit(Ext.isObject(this.submitOnEnter) ? this.submitOnEnter : undefined);

    Where I can find the ExtJS 2.x API documentation? Because Ext.isObject doesn't exist.

    I have test this:

    this.submit(true ? this.submitOnEnter : undefined);

    but it's don't work

    Thanks for help

    Jim

  10. #10
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Change:
    Ext.isObject(this.submitOnEnter)
    to
    typeof this.submitOnEnter == 'object'

Page 1 of 2 12 LastLast

Posting Permissions

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