从组合框中删除输入光标 [英] Remove typing cursor from combobox
问题描述
我使用的是 ExtJS 组合框.关注组合框时会出现打字光标.我尝试在创建组合框时实现 editable: false
,但它仅对 chrome 有帮助.
I am using an ExtJS combobox. There is a typing cursor when focusing on the combobox. I tried to implement editable: false
when creating the combobox, but it helped only for chrome.
还尝试了 clearListeners()
函数以查看这是否适用于该光标 - 没有帮助,它仍然出现在 FireFox 和 IE 中.
Also tried clearListeners()
function to see if this works on that cursor - didn't help, it still appears in FireFox and IE.
另一个想法是在组合框中的输入字段上设置 disabled
.当我手动完成时,它有所帮助.
The other idea is to set disabled
on the input field in combobox. When I did it manually, it helped.
但是当我写下一个
Ext.get('bu-encodingcount-combobox').select('input').set({disabled:'disabled'});
它没有帮助 - 不知道,也许表达是错误的.
it didn't help - don't know, maybe the expression is wrong.
推荐答案
你看到光标的原因是因为组合框获得了焦点,所以处理这个问题的最简单方法是将焦点移到下拉选择器上组合获得焦点.
The reason you see a cursor is because the combobox gets the focus, so the easiest way to handle this is to move the focus onto the drop down picker whenever the combo gets the focus.
只需将此 onFocus
配置添加到您的组合框配置:
Simply add this onFocus
config to your combobox configuration:
// example combobox config
xtype: 'combo',
allowBlank: false,
forceSelection: true,
valueField:'id',
displayField:'name',
store: myStore,
// add this "onFocus" config
onFocus: function() {
var me = this;
if (!me.isExpanded) {
me.expand()
}
me.getPicker().focus();
},
另外,如果这是一个 forceSelection: true
组合框,我只建议这样做.它会破坏用户在字段中输入任何内容的能力.
Also, I would only recommend doing this if this is a forceSelection: true
combobox. It will ruin a users ability to type anything into the field.
这篇关于从组合框中删除输入光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!