1

I am currently working on an old project with ExtJS 3.0.0, without possibility to upgrade version. My goal is to make a combobox always open, so that the user does not have to click the arrow in order to view the options.

I found out that by overriding the collapse event listener, I can prevent the combobox from closing once it is expanded

   myCombo.addListener(
        'collapse',
        function() { 
            this.expand();
         }
    );

However I cannot find any way to expand it programmatically once the panel is rendered. I experimented with specialkey and keypress events, but I do not know how they should be triggered.

Any ideas on how I could achieve this?

dchar
  • 1,665
  • 2
  • 19
  • 28

1 Answers1

0

a key press event should work as following,

you could try (extjs):

new Ext.form.TextField({
    ...
    enableKeyEvents: true,
    listeners: {
        keyup: function(form, e) {
            alert(e.getKey()); 
            if (e.getKey() == "keyA"){
                  alert("key A has been pressed");
           }
        }
    }
}); 

or try (js):

    listen: function () {
        document.addEventListener('keydown', function (key) {
            if (key.keyCode === 87){
          alert("pressed W")
           }
        });

for a list of keycodes visit https://gist.github.com/lbj96347/2567917

more information could be found here aswell https://forum.sencha.com/forum/showthread.php?52786-about-textfield-keypress-event

nubo
  • 9
  • 5
  • Yes I have seen the listener part, but I do not know how to trigger it. For example, something like myCombo.fireEvent('specialkey', ???). The keycode I could use is 40 (Arrow Down), as this seems to expand the combobox. Also, I do not know how to place automatically the cursor inside the field once the panel is rendered. – dchar Oct 13 '21 at 06:35
  • take a look at this https://stackoverflow.com/questions/8380759/why-isnt-this-textarea-focusing-with-focus – nubo Oct 13 '21 at 06:47
  • for further notice you cannot move the cursor, however you can let it focus by code – nubo Oct 13 '21 at 06:48