1

我的应用程序中有很多 TextField,都存在相同的问题:按下右侧的清除图标后,此文本框的焦点丢失。

该解决方案 有效但效率不高,因为那时我必须为每个文本字段都这样做:

                {
                    xtype: 'textfield',
                    label: 'Name',
                    onClearIconTap: function() {
                                        this.setValue('');
                                        console.log('onClearTap');
                                    }
                }

我遇到了这个页面,覆盖了该事件,但它不起作用。这将是一个首选的解决方案:

有什么帮助吗?

4

2 回答 2

3

以下是如何在 Sencha Touch 2 的 app.js 启动函数中覆盖该函数:

Ext.field.Text.override({
        onClearIconTap: function() {
            this.setValue('');
            this.focus();
            console.log('global onClearTap');
        }
    });

http://jsfiddle.net/QYJpc/46/

于 2012-10-31T12:08:40.890 回答
0

一个更好的解决方案(适用于 touch 2.3.0):

Ext.define('MyApp.override.field.Text', {
    override: 'Ext.field.Text',
    // @private
    doClearIconTap: function(me, e) {
        me.setValue(this.originalValue);

        me.focus();

        //sync with the input
        me.getValue();
    }
});
于 2013-10-10T08:16:32.893 回答