Let Esc and a click on empty space deselect Design feature and body rows

This commit is contained in:
SoftFever
2026-10-05 02:50:38 +08:00
parent a29e3078e8
commit 4cb6ca7ecb
7 changed files with 36 additions and 5 deletions
+21 -3
View File
@@ -3826,6 +3826,12 @@ DesignPanel::DesignPanel(wxWindow* parent)
: _L("Nothing selected"));
m_status->Refresh();
});
// A click on nothing drops a list row as it drops a pick. Not while a card is open: the
// feature being edited keeps its row.
m_viewport->set_on_empty_pick([this] {
if (m_active == Tool::None && deselect_rows())
set_status(StatusKind::Info, _L("Nothing selected"));
});
// Visual Extrude gizmo (C5b): dragging/editing the in-canvas depth arrow writes the
// matching spin field and re-previews (which re-feeds the gizmo with the new depth).
@@ -7526,6 +7532,16 @@ int DesignPanel::tree_body_selection() const
return m_parts == nullptr ? -1 : m_parts->selection();
}
// Unselect the Feature tree and Bodies rows; each list's on_select clears what its row lit. True
// if a row was selected.
bool DesignPanel::deselect_rows()
{
const bool any = (m_tree && tree_selection() != wxNOT_FOUND) || tree_body_selection() >= 0;
if (m_tree) m_tree->unselect();
if (m_parts) m_parts->unselect();
return any;
}
void DesignPanel::update_section_flip_btn()
{
if (m_section_flip_btn) m_section_flip_btn->Enable(m_section_on);
@@ -11763,11 +11779,12 @@ void DesignPanel::escape()
}
return;
case CadLevel::Idle:
case CadLevel::Idle: {
// Deselect. In a sketch this is the floor: the session is left through Finish or Cancel,
// both of which say which one they are, and never through a key pressed on the way out of
// something else.
if (m_viewport && m_viewport->clear_any_selection()) {
// something else. The Feature tree and Bodies rows count as selections too.
const bool row = deselect_rows();
if ((m_viewport && m_viewport->clear_any_selection()) || row) {
set_status(StatusKind::Info, wxString());
return;
}
@@ -11783,6 +11800,7 @@ void DesignPanel::escape()
}
return;
}
}
}
bool DesignPanel::menu_can_undo_redo(bool redo) const