diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-05-22 14:32:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-05-22 16:33:38 +0200 |
commit | 2a7bb352a9d6aa74495c03872c8c6150cbfc7a50 (patch) | |
tree | be3aa9fb309316bce4ef2d2e365fe2ea2c9d4817 /sfx2/source | |
parent | 7d64beb17dc46203334de53f65ef955083ce5b46 (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')
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 3 |
2 files changed, 30 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; } diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 05746df094fc..57b95edf9191 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -207,6 +207,9 @@ protected: void SaveFactoryStyleFilter( SfxObjectShell const * i_pObjSh, sal_Int32 i_nFilter ); SfxObjectShell* SaveSelection(); + void PrepareMenu(const Point& rPos); + void ShowMenu(const CommandEvent& rCEvt); + public: SfxCommonTemplateDialog_Impl(SfxBindings* pB, vcl::Window*, weld::Builder* pBuilder); |