分机 JS 6.6
经典工具包,一个文本字段有selectOnFocus : true/false 所以当组件获得焦点时,文本字段中的数据全部被选中
items: [{
xtype: 'textfield',
selectOnFocus: true
}]
现代工具包没有这个属性。我理解现代都符合 CSS3 并非常适合移动设备之间的需求,以及使用移动设备之间的差异。使用现代工具包,您可以通过
Ext.ComponentQuery.query('#textfield')[0].focus(true);
这在编写代码时很好。但我发现的问题是使用 Sencha Test 和以下代码
it("Checking existing email error notification", function () {
ST.component('textfield[name=\"createemail\"]').click();
ST.play([
{ type: "type", target: "textfield[name=\"createemail\"] => input", text: "someemail.email.com", caret:0 }
.... additional code here
]);
});
it("Some test", function() {
ST.component('textfield[name=\"createemail\"]').click();
.... additiona code here
});
在第二个测试块中,单击文本字段不会选择所有文本,因此如果我想替换现有文本,则必须将其清除或插入点从随机位置开始。
那么我们如何才能在 Modern 工具包中获得 selectOnFocus: 真正的功能呢?
我可以看到一些实例,在 Modern 中拥有此功能实际上更重要,因为在移动设备上 ctrl 'a' 不是一个选项。