PDA

View Full Version : [FIXED-391] Ext.form.Field hasfocus and focus() dont work



Theodosis
2 Oct 2010, 1:10 PM
Hello! I think there is a problem with Ext.form.Field hasfocus config option, and focus function on iPod touch.

expected behaviour: The field gets focused, and the keyboard opens.
real behaviour: Nothing happens.


Please, fix that

BrendanC
4 Oct 2010, 10:19 AM
Please say what version you are using and if possible post a sample of your code.

Theodosis
4 Oct 2010, 10:27 AM
I am using the version 0.96, and a sample of code is the following



new Ext.form.FormPanel({ //Login
id: 'LoginForm',
cls: 'sessionform',
method: "POST",
url: window.base + '?resource=session&method=create',
items:[{
cls: 'h2',
html: '<h2>wellcome</h2>',
}, {
id: 'LoginUsername',
cls: 'field',
xtype: 'textfield',
hasFocus: true,
label: 'Nickname',
name: 'username',
required: true,
listeners: {
afterrender: function(){
Ext.getCmp( 'LoginUsername' ).focus();
}
}
}, {
id: 'LoginPassword',
cls: 'field',
xtype: 'passwordfield',
label: 'password',
name: 'password',
required: true
}, {
cls: 'login',
xtype: 'button',
text: 'Enter',
ui: 'confirm',
width: 120,
handler: Session.Login.Do
}]
})


I tried that, and the same without the afterrender listener. It works on a desktop browser ( chrome ), but not on Safari for iPod.

BrendanC
4 Oct 2010, 1:14 PM
Thanks for the bug report.

Nostromo
4 Oct 2010, 11:19 PM
Also came across the same problem a few days ago.

I posted the problem in an existing thread about the problem, maybe didnt get picked up because the status was already changed to FIXED.

http://www.sencha.com/forum/showthread.php?107022-FIXED-230-textfields-unresponsive-to-first-taps-on-iOS-devices

BrendanC
5 Nov 2010, 1:35 PM
Appears to be fixed in the most recent release.

mathos
15 Nov 2010, 4:00 PM
Hello all,
I have this issue inside 1.0 on an Android tablet and iPad (4.2).

The focus() does not seem to function.
It works on Firefox on the Mac btw ;p



Ext.setup(
{
icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: true,
onReady: function()
{
var form = new Ext.form.FormPanel(
{
url: 'transactions.php',
items: [
{
xtype: 'fieldset',
title: 'Barcode Entry',
instructions: 'Please enter the barcode above.',
defaults:
{
required: true,
labelAlign: 'left'
},
items: [
{
id: 'BarcodeId',
xtype: 'textfield',
name: 'barcode',
//label: 'Barcode',
showClear: true,
//labelAlign: 'right',
autoCapitalize: false,
listeners:
{
afterrender: function()
{
Ext.getCmp( 'BarcodeId' ).focus();
}
}
}]
}]
});

var panel = new Ext.Panel(
{
fullscreen: true,
items: form,
layout: 'fit'
});
}
});


Any idea? Am I doing this wrong ?

This is version 1.0 btw.

Jacky Nguyen
15 Nov 2010, 11:12 PM
The focus method is there following browser's common standards. Unfortunately on mobile webkit there's currently no known way to programmatically focus on form fields without user's interaction. The only workaround right now is to execute focus when another element, e.g a label, get clicked.

However if you need one field to be focused right after it's introduced (rendered) into the DOM tree, you can try the autofocus attribute / config

mathos
20 Nov 2010, 1:40 AM
Thanks for the response. Shame there is not standard for this.

The autoFocus attribute, is that under the fields? I can not find it in the touch docs.

Kind regards, Mathos.