优化单元格进入编辑状态后,能跟随区域移动

This commit is contained in:
睿 安
2026-01-29 00:23:46 +08:00
parent 76be13001f
commit 415d9ab518
14 changed files with 36 additions and 6 deletions

View File

@@ -730,11 +730,35 @@ namespace ezui {
void TableView::OffsetX(int offset) {
m_scrollOffsetX = -offset;
// 如果正在编辑,更新编辑框位置
if (m_editing && m_editBox->IsVisible() && m_editRow >= 0 && m_editCol >= 0) {
if (m_editCol < (int)m_columns.size() && m_editRow < (int)m_rowHeights.size()) {
int x = GetColumnX(m_editCol);
int y = GetRowY(m_editRow);
int width = m_columns[m_editCol].Width;
int height = m_rowHeights[m_editRow];
m_editBox->SetRect(Rect(x, y, width, height));
}
}
Invalidate();
}
void TableView::OffsetY(int offset) {
m_scrollOffsetY = -offset;
// 如果正在编辑,更新编辑框位置
if (m_editing && m_editBox->IsVisible() && m_editRow >= 0 && m_editCol >= 0) {
if (m_editCol < (int)m_columns.size() && m_editRow < (int)m_rowHeights.size()) {
int x = GetColumnX(m_editCol);
int y = GetRowY(m_editRow);
int width = m_columns[m_editCol].Width;
int height = m_rowHeights[m_editRow];
m_editBox->SetRect(Rect(x, y, width, height));
}
}
Invalidate();
}