选项卡按钮功能

Tab Button Functionality

本文关键字:功能 按钮 选项      更新时间:2023-09-26

有没有办法指定在 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'
}