PDA

View Full Version : Add a special keys event to htmleditor (detect enter key)



mattx33sayWHAT
15 Jun 2009, 6:36 PM
I'm trying to detect when a user pressed enter using the html editor. heres my code

var form = new Ext.form.FormPanel({
baseCls: 'x-plain',
labelWidth: 55,
items: [{
contentEl: 'bl',
anchor: '100% -80' // anchor width by percentage
},{
xtype: 'htmleditor',
enableAlignments: false,
enableLists: false,
enableSourceEdit: false,
enableFontSize: false,
hideLabel: true,
name: 'msg',
anchor: '100%',
listeners: {
specialkey: function(f,e){
alert('asdf');
if ( e.getKey() == e.RETURN || e.getKey() == e.ENTER ) {

}
}
}
}]
});

win = new Ext.Window({
title: 'Chat with MattX33sayWHAT',
width: 500,
height:300,
minWidth: 300,
minHeight: 200,
layout: 'fit',
plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: form
});

wcasado
20 Dec 2009, 6:43 PM
I wanted to add ENTER key functionality to a combobox and your sample code work perfectly for our needs.
combobox ...
..........
listeners: {
specialkey: function(f,e){
if ( e.getKey() == e.RETURN || e.getKey() == e.ENTER ) {
//do our stuff......
}
}
}
.........

Thank you for sharing!

I love EXT!!!

wCasado