新增:单元格编辑完成回调;单击第一列选中整行

This commit is contained in:
睿 安
2026-01-28 16:51:51 +08:00
parent abcfc78596
commit 2ff880c267
17 changed files with 149 additions and 122 deletions

View File

@@ -159,6 +159,12 @@ namespace ezui {
int m_lastClickRow = -1;
int m_lastClickCol = -1;
// 选中行非CheckBox模式下通过单击第一列选中的行
int m_selectedRow = -1;
// 编辑前的原始值(用于编辑完成回调)
UIString m_editOriginalValue;
private:
void Init();
@@ -236,13 +242,17 @@ namespace ezui {
virtual const Size& GetContentSize() override;
public:
// 选中行背景色当第一列为CheckBox且被选中时使用
// 选中行背景色当第一列为CheckBox且被选中时使用,或者单击选中行时使用
Color SelectedRowBackColor = Color(0xFFADD8E6); // 浅蓝色
// 单元格内容变化回调
// 单元格内容变化回调(内容变化时立即触发)
// 参数: row, col, newValue
std::function<void(int, int, const UIString&)> CellValueChanged = nullptr;
// 单元格编辑完成回调编辑结束时触发比如TextBox失去焦点或按Enter时
// 参数: row, col, oldValue, newValue
std::function<void(int, int, const UIString&, const UIString&)> CellEditFinished = nullptr;
public:
TableView(Object* parentObject = nullptr);
virtual ~TableView();
@@ -376,6 +386,15 @@ namespace ezui {
// 获取所有选中的行索引
std::vector<int> GetCheckedRows() const;
// 获取当前选中的行非CheckBox模式通过单击第一列选中
int GetSelectedRow() const;
// 设置当前选中的行非CheckBox模式
void SetSelectedRow(int row);
// 清除选中行非CheckBox模式
void ClearSelection();
// 全选
void SelectAll();