how to implement place holder for wxTextCtrl Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
chenbin.sh
Experienced Solver
Experienced Solver
Posts: 64
Joined: Fri Apr 17, 2009 7:15 am
Location: Sydney, Australia
Contact:

how to implement place holder for wxTextCtrl

Post by chenbin.sh »

https://dl.dropboxusercontent.com/u/858 ... 17x151.png

I want to place the hint in the background of wxTextCtrl.
help me, help you.
http://blog.binchen.org
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: how to implement place holder for wxTextCtrl

Post by doublemax »

You could write "First name" as actual content into the control (with grey color). And when the user clicks into it (control gets focus), you check if it contains the placeholder text. And if yes, you clear the text.

If the focus leaves the control, check if it's empty. And if yes, put the placeholder text back in.
Use the source, Luke!
chenbin.sh
Experienced Solver
Experienced Solver
Posts: 64
Joined: Fri Apr 17, 2009 7:15 am
Location: Sydney, Australia
Contact:

Re: how to implement place holder for wxTextCtrl

Post by chenbin.sh »

Thanks, late I found there is an API SetHint() for wxTextCtrl.
help me, help you.
http://blog.binchen.org
Post Reply