sw/source/uibase/utlui/glbltree.cxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit dae57af4a7f24ea4672f2d99b18413b878e6a69a
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sat Feb 21 16:32:41 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sat Feb 21 20:12:17 2026 +0100

    Resolves: tdf#166902 ensure right clicked entry is selected
    
    Change-Id: Icee19b56e750ce525674a44a109f0fd52dab509a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199951
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/source/uibase/utlui/glbltree.cxx 
b/sw/source/uibase/utlui/glbltree.cxx
index 98ee87f12550..8a7dd8ab1fc7 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -272,6 +272,17 @@ IMPL_LINK(SwGlobalTree, CommandHdl, const CommandEvent&, 
rCEvt, bool)
     bool bPop = false;
     if (m_pActiveShell && 
!m_pActiveShell->GetView().GetDocShell()->IsReadOnly())
     {
+        // tdf#166902 ensure right clicked entry is selected
+        if (rCEvt.IsMouseEvent())
+        {
+            if (std::unique_ptr<weld::TreeIter> xEntry = 
m_xTreeView->get_dest_row_at_pos(rCEvt.GetMousePosPixel(), false))
+            {
+                // if clicked entry is not currently selected then clear 
selections and select it
+                if (!m_xTreeView->is_selected(*xEntry))
+                    m_xTreeView->set_cursor(*xEntry);
+            }
+        }
+
         std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(m_xTreeView.get(), 
u"modules/swriter/ui/mastercontextmenu.ui"_ustr));
         std::unique_ptr<weld::Menu> xPopup = 
xBuilder->weld_menu(u"navmenu"_ustr);
         std::unique_ptr<weld::Menu> xSubPopup = 
xBuilder->weld_menu(u"insertmenu"_ustr);

Reply via email to