Results 1 to 2 of 2

Thread: How do I catch ENTER while combobox is expanded?

  1. #1
    Sencha User
    Join Date
    May 2016
    Posts
    2
    Vote Rating
    0
      0  

    Default How do I catch ENTER while combobox is expanded?

    It seems on keypress the enter key is caught but the boundlist/picklist is already collapsed. I also need to trigger a store.load and append the record to the combobox store each time it returns data but I have to click enter twice if the combobox is expanded because the first enter only collapses the picklist/boundlist and the keypress is not caught by the listener.
    searchCombo.jpg

    Code:
                    xtype: 'combobox',
                    enableKeyEvents: true,
                    emptyCls: 'Search for',
                    emptyText: '\ue67a',
                    typeAhead: false,
                    flex: 1,
                    height: 30,
                    hideLabel: true,
                    hideTrigger: true,
                    autoSelect: false,
                    reference: 'comboSearch',
                    displayField: 'Value',
                    queryMode: 'local',
                    enableKeyEvents: true,
                    listConfig: {
                        // Custom rendering template for each item
                        getInnerTpl: function () {
                            return '<div data-qtip="{ToolTip}">{Value}' +
                                '</div>';
                        }
                    }
    

  2. #2
    Sencha User
    Join Date
    Jul 2017
    Posts
    58
    Answers
    6
    Vote Rating
    6
      1  

    Default

    You can override the onKeyEvent and modify the logic in there to do what you need:

    Code:
    Ext.define('YourApp.overrides.BoundListKeyNav', {
        override: "Ext.view.BoundListKeyNav",
    
        onKeyEnter: function (keyEvent) {
            var view = this.view,
            selModel = view.getSelectionModel(),
            field = view.pickerField;
    
            if (field.isExpanded) {
                this.selectHighlighted(keyEvent);
                field.collapse();
            } else {
                field.expand();
            }
        }
    });

Similar Threads

  1. How to catch keypress enter ?
    By lanciendunet in forum Sencha GXT Q&A
    Replies: 4
    Last Post: 4 Oct 2012, 11:00 PM
  2. Catch Enter in Chrome and Safary ???
    By finderetf in forum Ext: Discussion
    Replies: 0
    Last Post: 14 Aug 2011, 9:01 AM
  3. [OPEN-850] Can't catch enter key on TextField
    By scottw in forum Ext 3.x: Bugs
    Replies: 12
    Last Post: 15 Oct 2010, 10:12 AM
  4. Can't catch ENTER on textArea (specialkeys).
    By TotoTitus in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 18 Aug 2010, 4:54 AM
  5. Keymap catch enter ignores shift/ctrl/alt
    By mdissel in forum Ext 2.x: Help & Discussion
    Replies: 13
    Last Post: 10 Mar 2009, 9:34 AM

Tags for this Thread

Posting Permissions

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