PDA

View Full Version : specialkeys for htmleditor does not seem to fire in 3.1.1



moegal
24 Feb 2010, 12:41 PM
I cannnot capture the enter key with the htmleditor in the latest version. Am I doing this right?



xtype: 'htmleditor',
fieldLabel: 'Title',
name: 'title',
allowBlank: false,
anchor: '100%',
listeners: {
specialkey: function(field,e){
if (e.getKey() == e.ENTER) {
var form = field.ownerCt.getForm();
form.submit();
}
}
}


I am also seeing this in firefox 3.6

The 'charCode' property of a keyup event should not be used. The value is meaningless.

Thanks, Marty

moegal
30 Jul 2010, 3:17 AM
Does anyone have en example of capturing the enter key in the htmleditor?

I've tried:



listeners: {
initialize: function() {
if (Ext.isIE) {
Ext.EventManager.un(this.doc, 'keydown', this.fixKeys, this);
}
Ext.EventManager.on(this.doc, Ext.isGecko ? 'keypress' : 'keydown', function(e) {
if (e.getKey() == e.ENTER) {
alert('ENTER pressed');
}
}, this);
if (Ext.isIE) {
Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
}
}
}

And This



listeners: {
initialize: function() {
if (Ext.isIE) {
Ext.EventManager.un(this.doc, 'keydown', this.fixKeys, this);
}
Ext.EventManager.on(this.doc, Ext.isGecko ? 'keypress' : 'keydown', function(e) {
if(!e.shiftKey){
if (e.getKey() == e.ENTER) {
//console.log('ENTER pressed');
}
}
}, this);
if (Ext.isIE) {
Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
}
}
}


Neither work

moegal
30 Jul 2010, 4:17 AM
never mind here is what works:



listeners: {
initialize: function(editor) {
if (Ext.isIE) {
Ext.EventManager.un(this.getDoc(), 'keydown', this.fixKeys, this);
}
Ext.EventManager.on(this.getDoc(), Ext.isGecko ? 'keypress' : 'keydown', function(e) {
if(!e.shiftKey){
if (e.getKey() == e.ENTER) {
//action here
}
}
}, this);
if (Ext.isIE) {
Ext.EventManager.on(this.getDoc(), 'keydown', this.fixKeys, this);
}
}
}