From 17543ea69e405ef988e7c772ee214547df7b2dee Mon Sep 17 00:00:00 2001 From: tetektoza Date: Sun, 2 Nov 2025 16:40:11 +0100 Subject: [PATCH] Gui: Respect Selectable property for objects inside Part containers Currently if user selects object with `Selectable=false` property which is nested inside a Part container, for example `Part->Body->Pad`, parent Part container will get highlighted in the 3D view, even though the user clicked on a non-selectable child object. Cause of that is that tree view's `getTopParent()` function resolves nested objects selections to their top-level container. When a Pad inside Part is selected, `SoFCUnifiedSelection` was only checking Part's `isSelectable()` status, even though the target is `Pad`. So the fix is to resolve subname to get the final target object and checks its `isSelectable()` status before checking for highlighting. --- src/Gui/Selection/SoFCUnifiedSelection.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 32328d0cf7..c851341d9f 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -454,10 +454,25 @@ void SoFCUnifiedSelection::doAction(SoAction* action) // selection changes inside the 3d view are handled in handleEvent() App::Document* doc = App::GetApplication().getDocument(selectionAction->SelChange.pDocName); App::DocumentObject* obj = doc->getObject(selectionAction->SelChange.pObjectName); - ViewProvider* vp = Application::Instance->getViewProvider(obj); - if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) - && vp->isSelectable()) { - SoDetail* detail = nullptr; + ViewProvider*vp = Application::Instance->getViewProvider(obj); + + // check if the actual subobject being selected is selectable + bool isSelectable = false; + if (vp) { + if (selectionAction->SelChange.pSubName && selectionAction->SelChange.pSubName[0]) { + if (auto subObj = obj->getSubObject(selectionAction->SelChange.pSubName)) { + auto subVp = Application::Instance->getViewProvider(subObj); + isSelectable = subVp ? subVp->isSelectable() : false; + } else { + isSelectable = vp->isSelectable(); + } + } else { + isSelectable = vp->isSelectable(); + } + } + + if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) && isSelectable) { + SoDetail *detail = nullptr; detailPath->truncate(0); auto subName = selectionAction->SelChange.pSubName; App::ElementNamePair elementName;