[CLOSED] TriggerField and Enter key

  1. #1

    [CLOSED] TriggerField and Enter key

    I have a TriggerField with EnableKeyEvent true.
    When I press a key, a filtered search is launched and below the TriggerField
    a filtered TreePanel is loaded. It works fine, but I would like
    to disable the ENTER key. At the moment, when I have the focus in TriggerField
    and I press ENTER key, the whole page is reloaded and the whole Tree too. I simply
    would like that nothing happens when I press ENTER key.

    This is the piece of Code:
    
    var filterTree = function (tf, e) {
    
      ............
    
      if (e.getKey() == Ext.EventObject.ENTER) {
          e.stopEvent();
          return false;
      }else {
        var re = new RegExp(".*" + text + ".*", "i");
    
        tree.filterBy(function (node) {
          return re.test(node.data.text);
        });
      }
    };
    
           <ext:TriggerField
              ID="TriggerField1"
              runat="server"
              EnableKeyEvents="true">
              <Triggers>
                <ext:FieldTrigger Icon="Clear" />
              </Triggers>
              <Listeners>
                  <KeyPress Fn="filterTree"></KeyPress>
              </Listeners>
            </ext:TriggerField>
    Neither stopEvent, nor return false, seem to work.
    The code enters in the IF part, but it reloads the page all the same.

    Any idea?

    Many thanks
    Last edited by Daniil; Jul 08, 2014 at 1:03 PM. Reason: [CLOSED]
  2. #2
    Hi @alessandra.monica,

    Stopping the event in a KeyPress handler might be too late. I would try to stop it in a KeyDown or SpecialKey handler.
  3. #3
    Hi Daniil,

    thank you very much for you response.

    With the key down I had already tried and it doesn't work..... same as key press...

    As for Specialkey, could you please provide me with an example of how to use it?

    Thank you!
  4. #4
    I have tried with SpecialKey and it works perfectly!!

    You can close the thread.

    Thank you very much!

Similar Threads

  1. [CLOSED] Default Trigger on Enter when Focus is in TriggerField
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 07, 2014, 4:25 PM
  2. [0.8.2] Propertygrid and triggerfield
    By plykkegaard in forum 1.x Help
    Replies: 0
    Last Post: Jan 01, 2010, 5:23 PM
  3. TriggerField Validation
    By erey in forum 1.x Help
    Replies: 0
    Last Post: May 15, 2009, 9:11 PM
  4. TriggerField Use
    By erey in forum 1.x Help
    Replies: 5
    Last Post: May 14, 2009, 4:38 PM

Posting Permissions