Q: Displaying grey text in empty wxTextCtrl?

Robin Dunn robin at alldunn.com
Tue Nov 6 08:42:10 PST 2007


Petr Prikryl wrote:
> Hi, 
> 
> Is it possible to display a fixed grey text
> in the wxTextCtrl when the control data is empty?
> Is it somehow supported by wxWidgets?
> 
> You may know that kind of behaviour for example 
> from Mozilla Firefox 2, the right entry for entering
> text searched on the internet (it says "Google"
> in grey if the Google is chosen as default server
> for searching). Or Windows Vista login dialog
> where grey "Password" is displayed inside the control
> and you did not enter any character.
> 
> I like that feature as it may be implemented
> as enhancement of the original behaviour and 
> it does not break anything. It could probably
> be mimicked by the older wxTextCtrl, but it would
> be nicer if it was supported differently than
> via playing with text attributes... The control
> should return empty string even though the grey text
> 
> Thanks for any info/discussion,

It's possible to mimic this behavior within basic events from the plain 
wxTextCtrl.  Look at the generic implementation of wxSearchCtrl for an 
example.  It has a DescriptiveText attribute that is displayed if the 
widget is empty and does not have the focus.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wx-users mailing list