diff options
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Textbox.cpp | 8 | ||||
| -rw-r--r-- | src/interface/Textbox.h | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/interface/Textbox.cpp b/src/interface/Textbox.cpp index 12a4698..66af516 100644 --- a/src/interface/Textbox.cpp +++ b/src/interface/Textbox.cpp @@ -8,13 +8,15 @@ using namespace ui; -Textbox::Textbox(Point position, Point size, std::string textboxText): +Textbox::Textbox(Point position, Point size, std::string textboxText, std::string textboxPlaceholder): Label(position, size, ""), actionCallback(NULL), masked(false), border(true), mouseDown(false) { + placeHolder = textboxPlaceholder; + SetText(textboxText); cursor = text.length(); } @@ -231,6 +233,10 @@ void Textbox::Draw(const Point& screenPos) } else { + if(!text.length()) + { + g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, placeHolder, textColour.Red, textColour.Green, textColour.Blue, 170); + } if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255); } } diff --git a/src/interface/Textbox.h b/src/interface/Textbox.h index 120194e..1410405 100644 --- a/src/interface/Textbox.h +++ b/src/interface/Textbox.h @@ -25,8 +25,9 @@ protected: int cursor, cursorPosition; TextboxAction *actionCallback; std::string backingText; + std::string placeHolder; public: - Textbox(Point position, Point size, std::string textboxText); + Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = ""); virtual ~Textbox(); virtual void SetDisplayText(std::string text); |
