-
12 Nov 2007 8:47 PM #1
How to add the onkeyup event to a TextField object?
How to add the onkeyup event to a TextField object?
Hi,
I've tried the following, but the onkeyup event doesn't seem to fire for the TextField object?
Any pointers appreciated.Code:new Ext.form.TextField({ emptyText:'insert name', listeners: { 'onkeyup': function(obj) { alert('test fire'); } } }),Last edited by JeffHowden; 12 Nov 2007 at 9:25 PM. Reason: please use CODE tags.
-
12 Nov 2007 9:33 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Forest Grove, OR
- Posts
- 1,038
- Vote Rating
- 0
Unfortunately, the TextField class does not expose the onkeydown, onkeypress, or onkeyup events from the underlying input. Fortunately, I have an override that'll expose them for you.
http://extjs.com/forum/showthread.php?t=17532Jeff Howden
Ext JS - Support Team Volunteer
jeff@extjs.com
Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.
Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.
-
12 Nov 2007 9:59 PM #3
thanks Jeff.
It's worked (the keyup gets fired). Maybe my understanding of event buffering is wrong (I'm a newbie), but event buffering doesn't seem to work?
After the buffering delay period, the event gets fired in consecutive succession (if I enter 5 characters during the event buffering, the alert gets displayed 5 times)
Code:<snip> new Ext.form.TextField({ emptyText:'insert name', listeners: { 'keyup': { fn: function(obj) { alert('test'); }, delay: 1000 } } }), <snip>
-
12 Nov 2007 11:00 PM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Forest Grove, OR
- Posts
- 1,038
- Vote Rating
- 0
Maybe what you want is the buffer property of the config, instead of the delay.
Jeff Howden
Ext JS - Support Team Volunteer
jeff@extjs.com
Any and all code samples that are authored by me and posted on the Ext forums or website are hereby released into the public domain and I release anyone or entity of liability by using said code samples unless explicitly stated otherwise.
Opinions are mine and not necessarily endorsed by Ext, LLC. Please do not contact me directly for assistance unless requested by me.
-
12 Nov 2007 11:07 PM #5
As Jeff suggested, delay merely adds an extra time period before the event is fired. From the docs:
* delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.
* buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.
-
13 Nov 2007 3:28 AM #6
Thanks heaps guys - that did it!
Glad this forum exists!
-
6 Mar 2009 1:15 AM #7
hi,
i tried this and it works good,
but now i want to recognize which key was pressed, but i got some errors. anyone has a solution for that?
PHP Code:,listeners: {
'keyup': {
fn: function(key) {
if (key.getKey() == key.ENTER) {
alert('test');
}
}
-
6 Mar 2009 1:24 AM #8
http://extjs.com/deploy/dev/docs/?cl...d&member=keyup
Exactly what arguments does your handler get passed?Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
6 Mar 2009 1:31 AM #9
well thank you, this is my working solution
I'm wondering why the keyevents are disabled by default, cause this is something, you really need everywhere. has it something to do with saving memory or something?PHP Code:,listeners: {
'keyup': {
fn: function(field,key) {
if (key.getKey() == key.ENTER) {
alert('test');
}
}
Chriz
-
6 Mar 2009 2:35 AM #10
You don't really need it everywhere though.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote
