PDA

View Full Version : [FIXED-452] no way to capture char 13 (enter) in textfield as of 0.97



djkraz
21 Oct 2010, 7:02 AM
Pressing enter in a textfield now causes a blur event to fire but the keyup event still fires however it fires after the blur and therefore there is no keyCode in the keyup event. I agree with the new way of blurring on enter but we should still be able to capture the keyCode and even return false to cancel the blur if we decide to. This functionality is neccessary in single field forms such as search boxes. Right now I have to check for an undefined key code instead of keyCode 13 like I did prior to 0.97.

functional example code:


Ext.setup({
fullscreen: true,
onReady: function() {
var pnlSearch = new Ext.form.FormPanel({
items: [{
xtype: 'textfield',
listeners: {
keyup: function(textbox, event) {
console.log(event.browserEvent.keyCode);
},
blur: function(textbox) {
console.log('blur');
}
}
}]
});

var pnlMain = new Ext.Panel({
fullscreen: true,
layout: 'fit',
items: [pnlSearch]
});
}
});

BrendanC
21 Oct 2010, 3:49 PM
Thanks for the bug report.

benwhite
12 Nov 2010, 9:17 AM
Sencha should allow for some way to control the action triggered by the enter key.

As of RC1, here is the offending code within the sencha framework


onKeyUp: function(e) {
this.updateClearIconVisibility();

if (e.browserEvent.keyCode === 13) {
this.blur();
} else {
this.fireEvent('keyup', this, e);
}
}I wonder if this might be a better solution


onKeyUp: function(e) {
this.updateClearIconVisibility();

if (e.browserEvent.keyCode === 13) {
this.fireEvent('action', this, e);
this.blur();
} else {
this.fireEvent('keyup', this, e);
}
}

suzzer99
12 Nov 2010, 9:38 AM
+1

Our most critical issue right now is trying to find a way for the Go button to submit our forms. It would be nice to know if this is something Sencha has planned for the future. Or at least an easier way for us to "wire up" the go button than to attach listeners to every text field after render - as has been suggested in another thread. I've been trying but can't even get that to work.

I think users generally expect the Go button to do something other than just hide the keyboard. Right now the Go and Done buttons (iOS) do the same thing. Is this the planned Sencha behavior going forward?

Jacky Nguyen
13 Nov 2010, 4:58 AM
I'm making sure this can be made consistent on all the Androids on my table, not just iDevices, then will push it as soon as 1.0, or 1.1 right after that.

suzzer99
15 Nov 2010, 10:09 AM
Thanks Jacky! Just to make sure, when you implement this will work for iPhones as well right?

Jacky Nguyen
15 Nov 2010, 1:42 PM
In 1.0 we have added an 'action' event (http://dev.sencha.com/deploy/touch/docs/?class=Ext.form.Text) that you can listen to. Besides, 'keyup' will now still be fired on the return key, so you can capture it yourself.

Severance
26 Nov 2010, 4:47 AM
hello,

so now how can you hide automatically the keyboard when you push the "Go" button ?

suzzer99
11 Jan 2011, 3:05 PM
FYI - this only works on iOS 4.x. iOS 3.x sends keyCode = 10 instead of 13 when you press the Go Button.