summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-04-22 23:33:57 +0300
committerMichael Weghorn <m.weghorn@posteo.de>2023-04-23 06:20:06 +0200
commit20c86bd1059b54915190ce2e3dd39206d293aced (patch)
treeb32226e039b9b2951062869b678daf691dfb2ee9
parentda4c97968080707c91a15f53d07e6d062977b19a (diff)
tdf#153806 a11y Allow opening context menu of fav/recent char w/ keyboard
This is similar to commit 1f437264084fd173116965fa4d856aeafdfe7a98 Date: Sun Apr 2 00:36:44 2023 +0300 tdf#153806 a11y: Allow opening context menu in special char dlg using keyboard , but now for the character views in the "Recent Characters" and "Favorite Characters" sections in the special character dialog, and thus addresses this comment from the commit message of the above-mentioned commit: > Adding support for opening the context menu for the > recently used and favorite characters further down > in the special characters dialog is independent of this > and would have to be added separately. Turns out that the position returned by `CommandEvent::GetMousePosPixel` is good for the keyboard case as well, is right in the middle of the char view widget. Change-Id: I9f55b99398d557b19263bf531f6a857d274d3d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150815 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r--include/sfx2/charwin.hxx1
-rw-r--r--sfx2/source/control/charwin.cxx24
2 files changed, 17 insertions, 8 deletions
diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx
index 405af4bd53ad..a2beabc5b2df 100644
--- a/include/sfx2/charwin.hxx
+++ b/include/sfx2/charwin.hxx
@@ -44,6 +44,7 @@ private:
virtual void GetFocus() override;
virtual void LoseFocus() override;
virtual bool KeyInput(const KeyEvent&) override;
+ virtual bool Command(const CommandEvent&) override;
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
public:
SvxCharView(const VclPtr<VirtualDevice>& rVirDev);
diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx
index f80bd30b684d..b94d2bcd1e82 100644
--- a/sfx2/source/control/charwin.cxx
+++ b/sfx2/source/control/charwin.cxx
@@ -19,6 +19,7 @@
#include <vcl/settings.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/commandevent.hxx>
#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weldutils.hxx>
@@ -65,16 +66,10 @@ bool SvxCharView::MouseButtonDown(const MouseEvent& rMEvt)
}
maMouseClickHdl.Call(this);
+ return true;
}
- if (rMEvt.IsRight())
- {
- GrabFocus();
- Invalidate();
- createContextMenu(rMEvt.GetPosPixel());
- }
-
- return true;
+ return CustomWidgetController::MouseButtonDown(rMEvt);
}
bool SvxCharView::KeyInput(const KeyEvent& rKEvt)
@@ -92,6 +87,19 @@ bool SvxCharView::KeyInput(const KeyEvent& rKEvt)
return bRet;
}
+bool SvxCharView::Command(const CommandEvent& rCommandEvent)
+{
+ if (rCommandEvent.GetCommand() == CommandEventId::ContextMenu)
+ {
+ GrabFocus();
+ Invalidate();
+ createContextMenu(rCommandEvent.GetMousePosPixel());
+ return true;
+ }
+
+ return weld::CustomWidgetController::Command(rCommandEvent);
+}
+
void SvxCharView::InsertCharToDoc()
{
if (GetText().isEmpty())