diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-05 11:50:59 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-03-05 19:29:59 +0100 |
commit | 1986f8a3a577c68d8fd984f06108a4fc5769173e (patch) | |
tree | fdcb741237e5cdf843338bb56554fdfdf9c1bca7 | |
parent | ee499ffe6727c36a7cf6fd2a9c6f8a52b8a111c8 (diff) |
move MouseButtonDown logic to LayoutValueSet child
Change-Id: I8d70321856219988618d99ba5884b89950441b7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112012
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.cxx | 25 | ||||
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.hxx | 4 |
2 files changed, 10 insertions, 19 deletions
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index 513623a47fe9..1f245ea2c688 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -150,15 +150,7 @@ public: virtual void Resize() override; - virtual bool Command(const CommandEvent& rEvent) override - { - if (rEvent.GetCommand() == CommandEventId::ContextMenu) - { - mrMenu.ShowContextMenu(rEvent.IsMouseEvent() ? &rEvent.GetMousePosPixel() : nullptr); - return true; - } - return false; - } + virtual bool Command(const CommandEvent& rEvent) override; }; LayoutMenu::LayoutMenu ( @@ -312,19 +304,22 @@ void LayoutValueSet::Resize() ValueSet::Resize(); } -void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent) +bool LayoutValueSet::Command(const CommandEvent& rEvent) { + if (rEvent.GetCommand() != CommandEventId::ContextMenu) + return false; + // As a preparation for the context menu the item under the mouse is // selected. - if (rEvent.IsRight()) + if (rEvent.IsMouseEvent()) { - ReleaseMouse(); - sal_uInt16 nIndex = mxLayoutValueSet->GetItemId(rEvent.GetPosPixel()); + sal_uInt16 nIndex = GetItemId(rEvent.GetMousePosPixel()); if (nIndex > 0) - mxLayoutValueSet->SelectItem(nIndex); + SelectItem(nIndex); } - mxLayoutValueSet->MouseButtonDown(rEvent); + mrMenu.ShowContextMenu(rEvent.IsMouseEvent() ? &rEvent.GetMousePosPixel() : nullptr); + return true; } void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx b/sd/source/ui/sidebar/LayoutMenu.hxx index c93ac3e410d7..327a4939803c 100644 --- a/sd/source/ui/sidebar/LayoutMenu.hxx +++ b/sd/source/ui/sidebar/LayoutMenu.hxx @@ -77,10 +77,6 @@ public: // From ILayoutableWindow virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 nWidth) override; - /** Show a context menu when the right mouse button is pressed. - */ - virtual void MouseButtonDown(const MouseEvent& rEvent) override; - /** Call this method when the set of displayed layouts is not up-to-date anymore. It will re-assemble this set according to the current settings. |