问题是sencha touch没有添加小X。这是使用 html5 进行“搜索”输入的一个功能。要捕获此事件,您需要查找搜索事件。我如何解决这个问题是我编辑了 sencha-touch.js
我修改了-
if (this.fieldEl) {
this.mon(this.fieldEl, {
focus: this.onFocus,
blur: this.onBlur,
keyup: this.onKeyUp,
paste: this.updateClearIconVisibility,
mousedown: this.onBeforeFocus,
scope: this
});
成为-
if (this.fieldEl) {
this.mon(this.fieldEl, {
focus: this.onFocus,
blur: this.onBlur,
keyup: this.onKeyUp,
paste: this.updateClearIconVisibility,
mousedown: this.onBeforeFocus,
search: this.onSearch,
scope: this
});
Ext.form.Text 内部 = Ext.extend(Ext.form.Field, { ...
现在,在我的搜索字段实现中,我可以创建一个名为 onSearch 的函数,该函数将在调用“搜索”事件时调用。请注意,“搜索”事件不仅针对 X 调用,还针对某些诸如回车键之类的东西调用。底线是 sencha touch 1.1 根本不检查此事件,这是 X 触发事件的唯一一次,因此唯一的解决方案是修改 sencha-touch.js。