sd/source/ui/sidebar/MasterPagesSelector.cxx | 34 ++++++++++++++++----------- sd/source/ui/sidebar/MasterPagesSelector.hxx | 2 - 2 files changed, 22 insertions(+), 14 deletions(-)
New commits: commit d54ed594458b0124dac0b038f2b94f768089bfc8 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Dec 18 21:56:29 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Dec 19 09:21:18 2025 +0100 sd a11y: Allow opening MasterPagesSelector menu using keyboard This is similar to commit 39eacfffbdedfc0e19cf6b46e7dc30720041dcbb Author: Michael Weghorn <[email protected]> Date: Wed Dec 17 17:38:37 2025 +0100 sd a11y: Allow opening "Layout" context menu using keyboard , but for the IconView in the "Master Slides" sidebar deck in Impress. With this commit in place, pressing the context menu key (or Shift+F10) opens the context menu for the currently selected item, while previously, the context menu could only be opened using the mouse. Change-Id: I0854be6497a707d3e94d33d84b4aa07008d204d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195872 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index a39008ca15d9..a730950fa9a4 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -32,6 +32,7 @@ #include <DrawController.hxx> #include <SlideSorterViewShell.hxx> +#include <vcl/commandevent.hxx> #include <vcl/vclptr.hxx> #include <ViewShellBase.hxx> #include <o3tl/safeint.hxx> @@ -62,7 +63,7 @@ MasterPagesSelector::MasterPagesSelector(weld::Widget* pParent, SdDrawDocument& , mxSidebar(std::move(xSidebar)) { mxPreviewIconView->connect_item_activated(LINK(this, MasterPagesSelector, MasterPageSelected)); - mxPreviewIconView->connect_mouse_press(LINK(this, MasterPagesSelector, MousePressHdl)); + mxPreviewIconView->connect_command(LINK(this, MasterPagesSelector, CommandHdl)); mxPreviewIconView->connect_query_tooltip(LINK(this, MasterPagesSelector, QueryTooltipHdl)); Link<MasterPageContainerChangeEvent&,void> aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); @@ -129,19 +130,30 @@ IMPL_LINK_NOARG(MasterPagesSelector, MasterPageSelected, weld::IconView&, bool) return true; } -IMPL_LINK(MasterPagesSelector, MousePressHdl, const MouseEvent&, rMEvet, bool) +IMPL_LINK(MasterPagesSelector, CommandHdl, const CommandEvent&, rEvent, bool) { - if (!rMEvet.IsRight()) + if (rEvent.GetCommand() != CommandEventId::ContextMenu) return false; - const Point& rPos = rMEvet.GetPosPixel(); - std::unique_ptr<weld::TreeIter> pIter = mxPreviewIconView->get_item_at_pos(rPos); - if (!pIter) - return false; + Point aPos; + if (rEvent.IsMouseEvent()) + { + aPos = rEvent.GetMousePosPixel(); + std::unique_ptr<weld::TreeIter> pIter = mxPreviewIconView->get_item_at_pos(aPos); + if (!pIter) + return false; + mxPreviewIconView->select(*pIter); + } + else + { + std::unique_ptr<weld::TreeIter> pSelected = mxPreviewIconView->make_iterator(); + if (!mxPreviewIconView->get_selected(pSelected.get())) + return false; + aPos = mxPreviewIconView->get_rect(*pSelected).Center(); + } - mxPreviewIconView->select(*pIter); - ShowContextMenu(rPos); - return false; + ShowContextMenu(aPos); + return true; } IMPL_LINK(MasterPagesSelector, QueryTooltipHdl, const weld::TreeIter&, iter, OUString) diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx b/sd/source/ui/sidebar/MasterPagesSelector.hxx index 4f31d99995a6..0771210e477f 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.hxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx @@ -157,7 +157,7 @@ private: of an index for a token. */ DECL_LINK(MasterPageSelected, weld::IconView&, bool); - DECL_LINK(MousePressHdl, const MouseEvent&, bool); + DECL_LINK(CommandHdl, const CommandEvent&, bool); DECL_LINK(ContainerChangeListener, MasterPageContainerChangeEvent&, void); DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); commit 95d4f4114c2f5a0a8c20c2bac8186851814920df Author: Michael Weghorn <[email protected]> AuthorDate: Thu Dec 18 21:40:14 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Dec 19 09:21:10 2025 +0100 sd: Reuse weld::IconView::get_item_at_pos in MasterPagesSelector Use the method newly introduced in previous commit Change-Id: I637c6c59263b0238ba21bfe39ea866666b964778 Author: Michael Weghorn <[email protected]> Date: Thu Dec 18 21:26:41 2025 +0100 tdf#168594 weld: Add IconView::get_item_at_rect instead of implementing the same logic here again. While the previous commit was for the IconView used in Impress's "Properties" sidebar deck, this one is for the "Master Slides" one and right-clicking on one of the items opens a context menu as expected. Support for opening the context menu using the keyboard will be added separately. Change-Id: I6a32e4a96f670312be19fe84cc3e9822e7ef7eb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195871 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index aac41b6c5798..a39008ca15d9 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -134,17 +134,13 @@ IMPL_LINK(MasterPagesSelector, MousePressHdl, const MouseEvent&, rMEvet, bool) if (!rMEvet.IsRight()) return false; - const Point& pPos = rMEvet.GetPosPixel(); - for (int i = 0; i < mxPreviewIconView->n_children(); i++) - { - const ::tools::Rectangle aRect = mxPreviewIconView->get_rect(i); - if (aRect.Contains(pPos)) - { - mxPreviewIconView->select(i); - ShowContextMenu(pPos); - break; - } - } + const Point& rPos = rMEvet.GetPosPixel(); + std::unique_ptr<weld::TreeIter> pIter = mxPreviewIconView->get_item_at_pos(rPos); + if (!pIter) + return false; + + mxPreviewIconView->select(*pIter); + ShowContextMenu(rPos); return false; }
