简体   繁体   English

更改焦点ExtJs上的文本字段颜色

[英]Change Textfield colour on focus ExtJs

I'm trying to change the colour of a textfield when the user put the cursor on it, to be more easy to the user find the textfield. 我试图在用户将光标放在文本框上时更改文本框的颜色,以使用户更容易找到文本框。

I see in another post's how to change the colour with the css rules, and i found in the API, the fieldCls and focusCls to change the colours, but it isn't working, i know the problem is on the focus event that isn't fiering, 我在另一篇文章中看到了如何使用css规则更改颜色,并且我在API中找到了fieldCls和focusCls来更改颜色,但是它不起作用,我知道问题出在焦点事件上,猛烈地

Definition of the Button: 按钮的定义:

xtype:'textfield',
focusCls:'red',
fieldCls:'green',
listener: {
    'focus':function(){
        Ext.Msg.Alert('Focus','TextField have focus'); //This don't run
    }
}

CSS rules: CSS规则:

.red {
    background-image: none;
    background-color:#ff0000 !important;
}
.green {
    background-image: none;
    background-color:#00ff00 !important;
}

I made this test's on fiddle: http://jsfiddle.net/FabioJCosta/3ZZcZ/547/ 我在小提琴上做了这个测试: http : //jsfiddle.net/FabioJCosta/3ZZcZ/547/

Even when i'm forcing the focus with a button textfield.focus(false, 200); 即使当我用按钮textfield.focus(false,200);强制聚焦时; the focus event isn't fiering. 焦点事件并不激烈。

I hope this helps another people. 我希望这对其他人有帮助。

Thank You 谢谢

You don't need jQuery if I understand the question. 如果我理解这个问题,则不需要jQuery。

.green:focus {
    background-image: none;
    background-color:#ff0000 !important;
}
.green {
    background-image: none;
    background-color:#00ff00 !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM