diff --git a/include/guisan/widgets/textfield.hpp b/include/guisan/widgets/textfield.hpp index 7f7fe9a..cc6096c 100644 --- a/include/guisan/widgets/textfield.hpp +++ b/include/guisan/widgets/textfield.hpp @@ -62,6 +62,7 @@ #include "guisan/platform.hpp" #include "guisan/widget.hpp" +#include #include namespace gcn @@ -90,6 +91,11 @@ namespace gcn */ TextField(const std::string& text); + /** + * Destructor. + */ + ~TextField() override; + /** * Sets the text of the text field. * @@ -190,7 +196,7 @@ namespace gcn /** * Holds the text of the text field. */ - Text* mText = nullptr; + std::unique_ptr mText; /** * Holds the amount scrolled in x. If a user types more characters than diff --git a/src/widgets/textfield.cpp b/src/widgets/textfield.cpp index 23f46c2..eb20d1e 100644 --- a/src/widgets/textfield.cpp +++ b/src/widgets/textfield.cpp @@ -68,7 +68,7 @@ namespace gcn { - TextField::TextField() : mText(new Text()) + TextField::TextField() : mText(std::make_unique()) { setFocusable(true); @@ -78,7 +78,7 @@ namespace gcn adjustHeight(); } - TextField::TextField(const std::string& text) : mText(new Text(text)) + TextField::TextField(const std::string& text) : mText(std::make_unique(text)) { setFocusable(true); @@ -88,6 +88,8 @@ namespace gcn adjustSize(); } + TextField::~TextField() = default; + void TextField::setText(const std::string& text) { mText->setRow(0, text);