mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
LibGUI: GTableView should clear the selection if clicking outside items.
This commit is contained in:
parent
6af2ce0f7e
commit
62b4f39cd4
2 changed files with 11 additions and 4 deletions
|
@ -66,6 +66,10 @@ GModelIndex ProcessTableModel::selected_index() const
|
||||||
|
|
||||||
void ProcessTableModel::set_selected_index(GModelIndex index)
|
void ProcessTableModel::set_selected_index(GModelIndex index)
|
||||||
{
|
{
|
||||||
|
if (!index.is_valid()) {
|
||||||
|
m_selected_row = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (index.row() >= 0 && index.row() < m_pids.size())
|
if (index.row() >= 0 && index.row() < m_pids.size())
|
||||||
m_selected_row = index.row();
|
m_selected_row = index.row();
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,12 +58,15 @@ void GTableView::mousedown_event(GMouseEvent& event)
|
||||||
auto adjusted_position = event.position().translated(0, m_scrollbar->value());
|
auto adjusted_position = event.position().translated(0, m_scrollbar->value());
|
||||||
if (event.button() == GMouseButton::Left) {
|
if (event.button() == GMouseButton::Left) {
|
||||||
for (int i = 0; i < item_count(); ++i) {
|
for (int i = 0; i < item_count(); ++i) {
|
||||||
if (!row_rect(i).contains(adjusted_position))
|
if (row_rect(i).contains(adjusted_position)) {
|
||||||
continue;
|
m_model->set_selected_index({ i, 0 });
|
||||||
m_model->set_selected_index({ i, 0 });
|
update();
|
||||||
update();
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_model->set_selected_index({ });
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTableView::paint_event(GPaintEvent&)
|
void GTableView::paint_event(GPaintEvent&)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue