diff --git a/include/guisan/widgets/textbox.hpp b/include/guisan/widgets/textbox.hpp index 4140240..407f864 100644 --- a/include/guisan/widgets/textbox.hpp +++ b/include/guisan/widgets/textbox.hpp @@ -57,15 +57,15 @@ #ifndef GCN_TEXTBOX_HPP #define GCN_TEXTBOX_HPP -#include -#include -#include - #include "guisan/keylistener.hpp" #include "guisan/mouselistener.hpp" #include "guisan/platform.hpp" #include "guisan/widget.hpp" +#include +#include +#include + namespace gcn { class Text; @@ -91,6 +91,11 @@ namespace gcn */ TextBox(const std::string& text); + /** + * Destructor. + */ + ~TextBox() override; + /** * Sets the text of the text box. * @@ -272,7 +277,7 @@ namespace gcn /** * Holds the text of the text box. */ - Text* mText = nullptr; + std::unique_ptr mText; /** * True if the text box is editable, false otherwise. diff --git a/src/widgets/textbox.cpp b/src/widgets/textbox.cpp index cfad02f..22aeb88 100644 --- a/src/widgets/textbox.cpp +++ b/src/widgets/textbox.cpp @@ -71,7 +71,7 @@ namespace gcn TextBox::TextBox() : TextBox("") {} - TextBox::TextBox(const std::string& text) : mText(new Text(text)) + TextBox::TextBox(const std::string& text) : mText(std::make_unique(text)) { setFocusable(true); @@ -81,6 +81,8 @@ namespace gcn setFrameSize(1); } + TextBox::~TextBox() = default; + void TextBox::setText(const std::string& text) { mText->setContent(text);