有没有办法指定在 EXTJS 中按下键盘上的 TAB 按钮时会发生什么?在某个文本字段中,我希望在文本字段中输入信息并按 TAB 键后,它可以直接 TAB 到提交按钮。
这在 EXTJS 中可能吗?
最佳答案
正如您已经建议的那样,您可以为 specialkey 使用监听器您的文本字段上的事件:
{
xtype: 'textfield',
name: 'myfield',
listeners: {
specialkey: function(field, e) {
if (e.getKey() == e.TAB) {
e.preventDefault();
Ext.getCmp('mybutton').focus();
}
}
}
}
编辑:您也可以使用负值 tabIndexes 来实现这一点, 但只有在您的文本字段和提交按钮之间没有其他字段(或其他可能获得焦点的项目)时,这才会正常工作:
{
xtype: 'textfield',
name: 'myfield1',
tabIndex: -1
},{
xtype: 'textfield',
name: 'myfield2',
tabIndex: -1
},{
xtype: 'button',
name: 'mybutton'
}
关于javascript - 选项卡按钮功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19687036/