summaryrefslogtreecommitdiff
path: root/sfx2/source/dialog/templdlg.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-05-22 14:32:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-05-22 16:33:38 +0200
commit2a7bb352a9d6aa74495c03872c8c6150cbfc7a50 (patch)
treebe3aa9fb309316bce4ef2d2e365fe2ea2c9d4817 /sfx2/source/dialog/templdlg.cxx
parent7d64beb17dc46203334de53f65ef955083ce5b46 (diff)
Resolves: tdf#133183 select style under mouse on right click context menu
Change-Id: I4317f6702b7a0e172d059fe83614aab94845b201 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94690 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source/dialog/templdlg.cxx')
-rw-r--r--sfx2/source/dialog/templdlg.cxx31
1 files changed, 27 insertions, 4 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index cd54f9290867..18be2cd2e1c6 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -319,25 +319,48 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupFlatMenuHdl, const CommandEvent&, r
if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
return false;
+ PrepareMenu(rCEvt.GetMousePosPixel());
+
if (mxFmtLb->count_selected_rows() <= 0)
{
EnableEdit(false);
EnableDel(false);
}
- return PopupTreeMenuHdl(rCEvt);
+ ShowMenu(rCEvt);
+
+ return true;
}
-IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
+void SfxCommonTemplateDialog_Impl::PrepareMenu(const Point& rPos)
{
- if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
- return false;
+ weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
+ std::unique_ptr<weld::TreeIter> xIter(pTreeView->make_iterator());
+ if (pTreeView->get_dest_row_at_pos(rPos, xIter.get()) && !pTreeView->is_selected(*xIter))
+ {
+ pTreeView->unselect_all();
+ pTreeView->select(*xIter);
+ FmtSelectHdl(*pTreeView);
+ }
+}
+void SfxCommonTemplateDialog_Impl::ShowMenu(const CommandEvent& rCEvt)
+{
CreateContextMenu();
weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
OString sCommand(mxMenu->popup_at_rect(pTreeView, tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
MenuSelect(sCommand);
+}
+
+IMPL_LINK(SfxCommonTemplateDialog_Impl, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
+{
+ if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
+ return false;
+
+ PrepareMenu(rCEvt.GetMousePosPixel());
+
+ ShowMenu(rCEvt);
return true;
}