sw/source/uibase/utlui/content.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit eb895e42d1327a9263f53768d84c89a5ce6e8e63
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Sun Nov 28 15:41:26 2021 -0900
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 30 16:32:24 2021 +0100

    SwNavigator: keep entries selected on right-click
    
    when click position is on a selected entry unless root is in the
    selections then select root entry only
    
    Fixes regression from commit c4016f246fde835c0cfdabbb7cc35bc6dd48fb24
    
    Applies to root content navigation view for content types where multi-
    selection is possible.
    
    Change-Id: I3eb3b3f1eaaee39543700b8b7e3087d2795b3cdb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126017
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>
    (cherry picked from commit cb14adfd8cd593da4c429fcefba48531c10e47ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126100
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/uibase/utlui/content.cxx 
b/sw/source/uibase/utlui/content.cxx
index 0dbbd73949cc..44c610341fea 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -1533,10 +1533,18 @@ IMPL_LINK(SwContentTree, CommandHdl, const 
CommandEvent&, rCEvt, bool)
 
     grab_focus();
 
+    // select clicked entry or limit selection to root entry if needed
     if (std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
             rCEvt.IsMouseEvent() &&  m_xTreeView->get_dest_row_at_pos(
                 rCEvt.GetMousePosPixel(), xEntry.get(), false))
-        m_xTreeView->set_cursor(*xEntry);
+    {
+        // if clicked entry is not currently selected then clear selections 
and select it
+        if (!m_xTreeView->is_selected(*xEntry))
+            m_xTreeView->set_cursor(*xEntry);
+        // if root entry is selected then clear selections and select it
+        else if (m_xTreeView->is_selected(0))
+            m_xTreeView->set_cursor(0);
+    }
 
     std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(m_xTreeView.get(), 
"modules/swriter/ui/navigatorcontextmenu.ui"));
     std::unique_ptr<weld::Menu> xPop = xBuilder->weld_menu("navmenu");

Reply via email to