feat: add a new awesome feature

This commit is contained in:
Ysm-04
2025-10-01 00:57:41 +08:00
parent 26f30cee39
commit 3509b2bc39
3 changed files with 30 additions and 3 deletions

View File

@@ -5,11 +5,12 @@ StellarX 项目所有显著的变化都将被记录在这个文件中。
格式基于 [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
并且本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
## [v2.0.1] - 2025 - 09 - 30
## [v2.0.1] - 2025 - 10 - 01
### 新增
- 文本框新增`setText`接口,可在外部设置文本框内容
- `TextBox`新增`setText`API,可在外部设置文本框内容
- `Button`新增`setButtonClick`API,允许通过外部函数修改按钮的点击状态,并执行相应的回调函数
## [v2.0.0] - 2025-09-21

View File

@@ -102,6 +102,8 @@ public:
void setButtonText(std::string text);
//设置按钮形状
void setButtonShape(StellarX::ControlShape shape);
//设置按钮点击状态
void setButtonClick(BOOL click);
//判断按钮是否被点击
bool isClicked() const;

View File

@@ -263,7 +263,7 @@ bool Button::isClicked() const
void Button::setFillMode(StellarX::FillMode mode)
{
buttonFillMode = mode;
this->buttonFillMode = mode;
this->dirty = true; // 标记需要重绘
}
@@ -320,6 +320,30 @@ void Button::setButtonShape(StellarX::ControlShape shape)
this->dirty = true;
}
//允许通过外部函数修改按钮的点击状态,并执行相应的回调函数
void Button::setButtonClick(BOOL click)
{
this->click = click;
if (mode == StellarX::ButtonMode::NORMAL && click)
{
if (onClickCallback) onClickCallback();
dirty = true;
// 清除消息队列中积压的鼠标和键盘消息,防止本次点击事件被重复处理
flushmessage(EX_MOUSE | EX_KEY);
}
else if (mode == StellarX::ButtonMode::TOGGLE)
{
if (click && onToggleOnCallback) onToggleOnCallback();
else if (!click && onToggleOffCallback) onToggleOffCallback();
dirty = true;
// 清除消息队列中积压的鼠标和键盘消息,防止本次点击事件被重复处理
flushmessage(EX_MOUSE | EX_KEY);
}
if (dirty)
draw();
}
std::string Button::getButtonText() const
{