PDA

View Full Version : keyup textField event



albert.sole
28 Apr 2008, 2:07 AM
I'm trying to create a text field that captures the key press event, but I can't make it work. I have read here(http://extjs.com/forum/showthread.php?p=160289) that enableKeyEvents must be set. But, where? in the TextField object?. Here is the code I use. Any idea?



<html>
<head>
<script type="text/javascript" src="./js/otherlibs/ext-2.0.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./js/otherlibs/ext-2.0.1/ext-all-debug.js"></script>
</head>
<body>
<div id='content'></div>
</body>

<script language="javascript">
Ext.onReady(function(){
var filterTextField = new Ext.form.TextField({
enableKeyEvents: true,
width: 100,
id: 'unique id',
fieldLabel: 'label',
name: 'unique name'
});

filterTextField.on('keyup', function(){
alert('keyup event fired');
});

filterTextField.render('content');
});
</script>
</html>

albert.sole
30 Apr 2008, 12:21 AM
http://extjs.com/forum/showthread.php?t=17532

albert.sole
30 Apr 2008, 1:00 AM
is that for ExtJS 1.0?

aconran
30 Apr 2008, 1:03 AM
It's for 2.x. Upgrade to 2.1 and you should be okay.

albert.sole
30 Apr 2008, 1:14 AM
thanks a lot.

Albert

calverte
6 May 2008, 9:02 AM
How can this be accomplished in conjunction with a HtmlEditor?:-?

Here is an excerpt from my code in which I have a HtmlEditor inside a panel:



new Ext.Panel({
bodyStyle: "padding: 10px; ",
id: "pnCurrtext",
layout: "fit",
title: "Current Text",
disabled: true,
items: [
{
enableKeyEvents: true,
enableSourceEdit: false,
name: "Currtext",
value: "N/A",
id: "Currtext",
xtype:"htmleditor"
} ], listeners: {
"keypress" : {
fn: function(){
Ext.MessageBox.alert("Saving draft...");
//Ext.fly('draft_saved').update('Saving draft...');
//Ext.fly('draft_saved').update('45 Draft auto-saved at ' + new Date().format('g:i:s A'));
}
}
},
dummy: true
})


Thanks in advance.

~Calvert

Seboss
23 Jun 2008, 12:06 PM
Hi,

I got some problems with enableKeyEvents and textfields.

Here's a code snippet:


var filterField = new Ext.form.TextField(
{
emptyText: "type your filter here...",
enableKeyEvents: true
});

filterField.on("keypress", myObj.filter, myObj);

var myGrid = new Ext.grid.GridPanel(
{
id: "my-grid",
tbar:
[
"Filter: ",
filterField // Here I add the textfield to the whole thing
],
...
});

myGrid.render("grid-div");


The problem is, the myObj.filter function is never called.
Tried with keydown, keyup and keypress to no avail. Events other than "key" events work just fine.

Am I missing something or did something wrong ? TIA.

Seboss
23 Jun 2008, 12:10 PM
Ok, I'm an *****. The project I'm currenly working on uses an earlier version of ExtJS.