# Background for textctrl

**URL:** <https://www.ruby-forum.com/t/background-for-textctrl/134889>\
**Category:** wxRuby\
**Created:** [April 15, 2008, 11:29pm UTC](https://www.ruby-forum.com/t/background-for-textctrl/134889 "2008-04-15T23:29:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerapcik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/edb3f5/32.png) [@gerapcik](https://www.ruby-forum.com/u/gerapcik)\
**Post date:** [April 15, 2008, 11:29pm UTC](https://www.ruby-forum.com/t/background-for-textctrl/134889/1 "2008-04-15T23:29:09Z")

</div>

hi,  
i have a small form with some textctrl. and i was wondering how to set  
background of them when i write something on them.  
i mean, i would like to give a another than default backgound color when  
i set focus/write something.

thanks a lot in advance, because i have seen some posts, and everyone  
has answered in a very gentile way. this is a thing that is missed in  
other parts

thanks again

---

<div class="post-metadata">

**Author:** ![gerapcik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/edb3f5/32.png) [@gerapcik](https://www.ruby-forum.com/u/gerapcik)\
**Post date:** [April 16, 2008, 12:14am UTC](https://www.ruby-forum.com/t/background-for-textctrl/134889/2 "2008-04-16T00:14:41Z")

</div>

Hi

Gerard Rakoczy wrote:

> i have a small form with some textctrl. and i was wondering how to set  
> background of them when i write something on them.  
> i mean, i would like to give a another than default backgound color when  
> i set focus/write something.  
> In the constructor for your TextCtrl, maybe something like:

evt\_set\_focus { self.background\_colour = Wx::RED }  
evt\_kill\_focus { self.background\_colour = Wx::WHITE }

I’m not sure that on all platforms, the native TextCtrl is allowed to  
change the background colour. But this works fine for me on OS X.

cheers  
alex
