diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f0255..a0344d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ StellarX 项目所有显著的变化都将被记录在这个文件中。 格式基于 [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 并且本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。 +## [v2.0.1] - 2025 - 09 - 30 +### 新增 + +- 文本框新增`setText`接口,可在外部设置文本框内容 ## [v2.0.0] - 2025-09-21 diff --git a/include/StellarX/textBox.h b/include/StellarX/textBox.h index 54afb27..b6f4d85 100644 --- a/include/StellarX/textBox.h +++ b/include/StellarX/textBox.h @@ -49,7 +49,9 @@ public: //设置边框颜色 void setTextBoxBorder(COLORREF color); //设置背景颜色 - void setTextBoxBk(COLORREF color); + void setTextBoxBk(COLORREF color); + //设置文本 + void setText(std::string text); //获取文本 std::string getText() const; diff --git a/src/textBox.cpp b/src/textBox.cpp index 2857073..4966b61 100644 --- a/src/textBox.cpp +++ b/src/textBox.cpp @@ -140,6 +140,14 @@ void TextBox::setTextBoxBk(COLORREF color) this->dirty = true; } +void TextBox::setText(std::string text) +{ + if(text.size() > maxCharLen) + text = text.substr(0, maxCharLen); + this->text = text; + this->dirty = true; +} + std::string TextBox::getText() const { return this->text;