Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my key events not working

Tags:

extjs

extjs6

Why are my key events not working in the following example? The 'blur' event works, but none of the key events work on my textfield (I also tried 'keydown').

I tried using the 'control' construct on the controller as well, but that doesn't work either.

Ext.define('Plus.view.MyController', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.mycontroller',
    control: {
        '#mytextfield': {
            blur: function() {
                alert("oink")
            },
            keypress: function() {
                alert("moo")
            },
            keyup: function() {
                alert("quack")
            }
        }
    }
});

Ext.define('Plus.view.MainView', {
    extend: 'Ext.container.Container',

    items: [{
        xtype: 'textfield',
        id: 'mytextfield',
        controller: 'mycontroller',
        listeners: {
            blur: function() {
                alert("oink 2")
            },
            keypress : function() {
                alert("moo 2")
            },
            keyup : function() {
                alert("quack 2")
            }
        }
    }]
});

Ext.application({
    name: 'Plus',
    autoCreateViewport: 'MainView',
    launch: function() {

    }
});

My fiddle is here :

https://fiddle.sencha.com/#fiddle/1d5d

Am I missing something obvious?

like image 775
Oliver Watkins Avatar asked Jan 06 '23 18:01

Oliver Watkins


1 Answers

keypress and keyup These event only fires if enableKeyEvents is set to true. Set this and your code will work. I created a fidller for you where code is working. Fiddle

like image 76
UDID Avatar answered Jan 20 '23 06:01

UDID